-
value type
type Signed (SIGNED) value range Unsigned (UNSIGNED) value range size describe TINYINT (-128,127) (0,255) 1byte small integer value SMALLINT (-32768,32767) (0,65535) 2bytes big integer value INT/INTEGER (-2147483648,2147483647) (0,4294967295) 4bytes big integer value BIGINT(Long) (-263,263-1) (0,2^64-1) 8bytes extremely large integer value FLOAT (-3.402823466 E+38,3.402823466351 E+38) 0 sum (1.175494351 E-38, 3.402823466 E+38) 4bytes single-precision floating-point value DOUBLE (-1.7976931348623157 E+308, 1.7976931348623157 E+308) 0 Sum (2.2250738585072014E-308, 1.7976931348623157E+308) 8bytes double-precision floating-point value DECIMAL decimal value (exact) example:
-
user age field
age tinyint unsigned
-
score 100
score double(4,1)
-
-
string type
type size describe CHAR 0-255 bytes Fixed-length string (need to specify the length) VARCHAR 0-65535 bytes Variable-length string (need to specify the length) BLOB 0-65 535 bytes Long text data in binary form TEXT 0-65 535 bytes long text data LONGTEXT 0-4 294 967 295 bytes extremely large text data example:
-
gender
gender char(1)
-
username
username varchar(64)
-
-
datetime type
type Format scope size describe DATE YYYY-MM-DD 1000-01-01 to 9999-12-31 3 date value TIME HH:MM:SS -838:59:59 to 838:59:59 3 time value or duration YEAR YYYY 1901 to 2155 1 year value DATETIME YYYY-MM-DD HH:MM:SS 1000-01-01 00:00:00 to 9999-12-31 23:59:59 8 Mixed date and time values TIMESTAMP YYYY-MM-DD 1970-01-01 00:00:01 to 2038-01-19 03:14:07 4 Mixed date and time values, timestamps example
-
Birthday
birthday date
-
update time
updatetime datetime
-
-
need
需求: 设计一张员工信息表,要求如下: 1. 编号(纯数字) 2. 员工工号 (字符串类型,长度不超过10位) 3. 员工姓名(字符串类型,长度不超过10位) 4. 性别(男/女,存储一个汉字) 5. 年龄(正常人年龄,不可能存储负数) 6. 身份证号(二代身份证号均为18位,身份证中有X这样的字符) 7. 入职时间(取值年月日即可) create table employee( id bigint comment '编号', workno varchar(10) comment '员工工号', name varchar(10) comment '员工姓名', gender char(1) comment '性别', age tinyint UNSIGNED comment '年龄', idcard char(18) comment '身份证号', entryDate date comment '入职时间' )comment '员工表';
MySQL Data Types
Guess you like
Origin blog.csdn.net/qq_45709416/article/details/132331739
Recommended
Ranking