mysql基礎資料型別 (Elementary Data Type),mysql資料類型

來源:互聯網
上載者:User

mysql基礎資料型別 (Elementary Data Type),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';

著作權聲明:博主原創文章,轉載請說明出處。http://blog.csdn.net/dzy21

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.