MySQL 8.0 支持的数据类型
1. 数值类型
- bit[(M)],比如 bit,bit(6),M 表示 bit 位的数量,取值 1~64,默认为 1
- tinyint[(M)][unsigned][ZEROFILL],取值范围 -128~127,无符号的取值范围 0~255
- bool,boolean
- smallint[(M)] [unsigned] [zerofill],取值范围为 -32768~32767,无符号的为 0~65535
- mediumint[(M)] [unsigned] [zerofill],取值范围 -8388608~8388607,无符号的为 0~16777215
- int[(M)] [unsigned] [zerofill],取值范围-2147483648~2147483647,无符号的为 0~4294967295
- integer[(M)] [unsigned] [zerofill],同 int
- bigint[(M)] [unsigned] [zerofill],取值范围-9223372036854775808~9223372036854775807,无符号的为0~18446744073709551615
- serial,同 bigint unsigned not null auto_increment unique
- decimal[(M[,D])] [unsigned] [zerofill],精确的符点型,不会丢失精度
- dec[(M[,D])] [unsigned] [zerofill],同 decimal
- numeric[(M[,D])] [unsigned] [zerofill],同 decimal
- fixed[(M[,D])] [unsigned] [zerofill],同 decimal
- float[(M,D)] [unsigned] [zerofill],float(M,D)是非标准的 MySQL 扩展写法,MySQL 8.0.17 版本开始,该语法已废弃
- float(p) [unsigned] [zerofill]
- double[(M,D)] [unsigned] [zerofill],double(M,D)是非标准的 MySQL 扩展写法,MySQL 8.0.17 版本开始,该语法已废弃
- double precision[(M,D)] [unsigned] [zerofill],同 double
- real[(M,D)] [unsigned] [zerofill],同 double
2. 日期与时间类型
- date
- datetime[(fsp)]
- timestamp[(fsp)]
- time[(fsp)]
- year[(4)]
3. 字符串数据类型
- [NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
- [NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name]
- BINARY[(M)]
- VARBINARY(M)
- TINYBLOB
- TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
- BLOB[(M)]
- TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
- MEDIUMBLOB
- MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
- LONGBLOB
- LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
- ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]
- SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]
4. 空间数据类型
- GEOMETRY
- POINT
- LINESTRING
- POLYGON
- MULTIPOINT
- MULTILINESTRING
- MULTIPOLYGON
- GEOMETRYCOLLECTION
5. JSON类型
- JSON
文章评论
共0条评论