1、数值类型:
BIT[(M)]
二进制位,M指定值的位数,从1到64(也就是说它能定义任意的介于1到64位之间的整数),如某字段的类型定义为BIT或BIT[1],它就只能取0或1,定义为BIT[2]只能取0~3之间的整数,如果没有指定M则默认M=1.
TINYINT[(M)] [UNSIGNED] [ZEROFILL]
8位整数,有符号数的取值范围是-128到127,无符号数的取值范围是0到255(此处M的取值范围是0到255,是用来控制显示宽度的,但实际上好像没用,区别BIT(M).)
BOOL,BOLLEAN
与TINYINT(1)同义.零被认为是false,非零数被认为是true.
SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
16位整数,有符号数的取值范围为-32768到32767,无符号数的取值范围是0到65535.
MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]
24位整数,有符号数取值范围是-8388608到8388607,无符号数的取值范围是0到16777215.
INT[(M)] [UNSIGNED] [ZEROFILL]
32位整数,有符号数的取值范围是-2147483648到2147483647,无符号数的取值范围是0到4294967295.
INTERGER[(M)] [UNSIGNED] [ZEROFILL]
同INT.
BIGINT[(M)] [UNSIGNED] [ZEROFILL]
64位整数,有符号数的取值范围是-9223372036854775808到9223372036854775807,无符号的取值范围是0到18446744073709551615.
二、日期和时间类型
三、字符(串)类型
English from MySQL 5.0 Reference Manual:
1. Overview of Numeric Types
BIT[(
M
)]
A bit-field type. M
indicates the number of bits per value, from 1 to 64. The default is 1 if M
is omitted.
This data type was added in MySQL 5.0.3 for MyISAM
, and extended in 5.0.5 to MEMORY
, InnoDB
, and BDB
. Before 5.0.3, BIT
is a synonym for TINYINT(1)
.
TINYINT[(
M
)] [UNSIGNED] [ZEROFILL]
A very small integer. The signed range is -128
to 127
. The unsigned range is 0
to 255
.
BOOL
, BOOLEAN
These types are synonyms for TINYINT(1)
. A value of zero is considered false. Non-zero values are considered true.
In the future, full boolean type handling will be introduced in accordance with standard SQL.
SMALLINT[(
M
)] [UNSIGNED] [ZEROFILL]
A small integer. The signed range is -32768
to 32767
. The unsigned range is 0
to 65535
.
MEDIUMINT[(
M
)] [UNSIGNED] [ZEROFILL]
A medium-sized integer. The signed range is -8388608
to 8388607
. The unsigned range is 0
to 16777215
.
INT[(
M
)] [UNSIGNED] [ZEROFILL]
A normal-size integer. The signed range is -2147483648
to 2147483647
. The unsigned range is 0
to 4294967295
.
INTEGER[(
M
)] [UNSIGNED] [ZEROFILL]
This type is a synonym for INT
.
BIGINT[(
M
)] [UNSIGNED] [ZEROFILL]
A large integer. The signed range is -9223372036854775808
to 9223372036854775807
. The unsigned range is 0
to 18446744073709551615
.