大數據類型
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';