The MySQL data types include:
- Number type (Numeric type)
- Date and Time type
- Type of string (string literal)
One, Number type (Numeric type)
We use M to represent the maximum display width of an integer type, the maximum display width is 255, and the display width is independent of the range the data type can represent.
Numeric types allow UNSIGNED (unsigned, greater than or equal to 0) and signed (Signed, default) properties.
SERIAL is BIGINT UNSIGNED not NULL auto_increment UNIQUE alias, you can create a table like this:
Create TableB (a serial); showCreate Tableb;+-------+----------------------------------------------------------------------------------------------------- ---------------------------------+| Table | Create Table |+-------+---------------------------------------------------------------------------------------------------- ----------------------------------+|B| CREATE TABLE' B ' (' A 'bigint( -) unsigned not NULLAuto_increment,UNIQUE KEY' A ' (' a ')) ENGINE=InnoDBDEFAULTCHARSET=Utf8mb4|+-------+----------------------------------------------------------------------------------------------------- ---------------------------------+
BIT (m): M takes a value of 1-64 and defaults to 1.
tinyint[(M)] [UNSIGNED] [zerofill],signed value: 128 to 127,unsigned value: 0 to 255.
BOOL, Boolean: Boolean type, which is synonymous with TINYINT (1). A value of 0 is considered incorrect, and a non-0 value is considered correct. True=1 and False=0, the other values are neither equal to true nor equal to FALSE.
smallint[(M)] [UNSIGNED] [Zerofill]
mediumint[(M)] [UNSIGNED] [Zerofill]
int[(M)] [UNSIGNED] [Zerofill]
integer[(M)] [UNSIGNED] [Zerofill]
bigint[(M)] [UNSIGNED] [Zerofill]
decimal[(M[,d]) [UNSIGNED] [Zerofill]
float[(m,d)] [UNSIGNED] [Zerofill]
double[(m,d)] [UNSIGNED] [Zerofill]
FLOAT (P) [UNSIGNED] [Zerofill]
Two, date and time type
DATE the supported range is ' 1000-01-01 ' to ' 9999-12-31 '. MySQL displays DATE values in ' yyyy-mm-dd ' format.
datetime[(FSP)] fsp:fractional seconds part seconds of the decimal point. The supported range is ' 1000-01-01 00:00:00.000000 ' to ' 9999-12-31 23:59:59.999999 '. MySQL displays DATETIME values in ' yyyy-mm-dd hh:mm:ss[.fraction] ' format
Three, String type
Reference: "refman-5.7" Chapter Data Types
MySQL data type