Home >Database >Mysql Tutorial >mysql基本数据类型_MySQL
大数据类型
CREATE TABLE DATA(fti TINYINT,fsi SMALLINT,
fmi MEDIUMINT,fi INT,fbi BIGINT);
int类型
CREATE TABLE data1(age INT(7));
float类型
CREATE TABLE data2(price FLOAT(5,2));
INSERT INTO data2 VALUES(13.1),(14.567);
查询结果:保留小数点后两位
SELECT * FROM data2;
char类型
CREATE TABLE data3(sname CHAR(10));
INSERT INTO data3VALUES('wers'),('ertdsasdfggh');
SELECT * FROM data3;
不够空格补齐,多余自动截取
时间类型:
CREATE TABLE data4(birthday DATE);
INSERT INTO data4 VALUES('2015-03-05'),(20150506);
SELECT * FROM data4;
enum类型
CREATE TABLE data5 (gender ENUM('M','F'));
INSERT INTO data5VALUES('M'),('m'),('f'),('yy'),(NULL);
SELECT * FROM data5;
SELECT COUNT(*) FROM data5 WHEREgender='M';