mysql笔记6之数据类型

1 区别一:

    varchar:可变长度的字符串。根据添加的数据长度决定占用的字符数

    char:固定长度的字符串

2区别二

    int:没有限制

    int(4):限制为4

3 区别三:

日期: date   datetime  timestamp

CREATE TABLE test3(

sdate DATE,   -- 日期:2017-01-11

vdate DATETIME, -- 日期 + 时间

rdate TIMESTAMP --  时间戳。用于记录数据的添加时间,或修改时间

)

INSERT INTO test3 VALUES(‘2017-01-11,'',);

INSERT INTO test3 VALUES('',2017-01-11’,);

INSERT INTO test3 VALUES('','',NULL); 

UPDATE test3 SET sdate=‘2017-01-11;

原文地址:https://www.cnblogs.com/lanjianhappy/p/6286499.html