Download presentation
Presentation is loading. Please wait.
1
Kirkwood Center for Continuing Education
Introduction to PHP and MySQL Kirkwood Center for Continuing Education By Fred McClurg, Copyright © 2016, Fred McClurg, All Rights Reserved.
2
Chapter Nine MySQL Data Types
3
MySQL Numeric Integer Data Types
Field Type Description Range Unsigned BIT[(m)] A bit-field type. 1 to 64 TINYINT[(m)] A very small integer. -128 to 127 0 to 255 BOOLEAN Synonym for TINYINT(1). TRUE or FALSE SMALLINT[(m)] A small integer. -32,768 to 32,767 (thousands) 0 to 65,535 MEDIUMINT[(m)] A medium-sized integer. -8,388,608 to 8,388,607 (millions) 0 to 16,777,215 INT[(m)] A normal-size integer. -2,147,483,648 to 2,147,483,647 (billions) 0 to 4,294,967,295 BIGINT[(m)] A large integer. -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (quintillion) 0 to 18,446,744,073,709,551,615
4
MySQL Numeric Decimal Data Types
Field Type Description FLOAT[(m,d)] A small (single-precision) floating-point number. DOUBLE[(m,d)] A normal-size (double-precision) floating-point number.
5
MySQL Date and Time Data Types
Field Type Description Format DATE A date. YYYY-MM-DD DATETIME A date and time combination. YYYY-MM-DD HH:MM:SS TIMESTAMP A timestamp whose values are stored as number of seconds since epoch (' :00:00'). TIME A time. HH:MM:SS YEAR[(2|4)] A year in two-digit or four-digit format. YYYY
6
MySQL String Data Types
Field Type Description Range CHAR[(m)] A fixed-length string that is always right-padded with spaces to the specified length. 0 to 255 VARCHAR(m) A variable-length string. m represents the maximum column length in characters. 0 to 65,535 bytes TEXT[(m)] Non-binary character string 65,535 character max. BLOB[(m)] Binary large object that can hold a variable amount of data. 65,535 byte max.
7
MySQL String Data Types (cont.)
Field Type Description Range TINYTEXT A small text column 255 character max MEDIUMTEXT A medium-sized text column 16,777,215 character max LONGTEXT A large text column 4,294,967,295 or 4GB character max ENUM('value1', 'value2', ) An enumeration A maximum of 65,535 distinct values SET('value1', 'value2', ) A set A maximum of 64 members
8
MySQL Default Data Type Values
Field Type Description CURRENT_DATE Returns the current date as a value in 'YYYY-MM-DD' CURRENT_TIME Returns the current time as a value in 'HH:MM:SS' CURRENT_TIMESTAMP or NOW (an alias for CURRENT_TIMESTAMP) Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' Example: CREATE TABLE book ( creation TIMESTAMP DEFAULT NOW() );
9
to be continued ...
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.