标签:values blog table height var 并且 val 声明 alter
常见数据类型有:
整数:tinyint、smallint、mediumint、int、bigint
浮点数:float、double
定点数:decimal
字符串:char、varchar、tinytext、text、mediumtext、longtext
日期:date、datetime、timestamp、year、time
整数的申明方式:
类型 | 声明方式 |
tinyint |
TINYINT[(M)] [UNSIGNED] [ZEROFILL] M默认为4 |
smallint |
SMALLINT[(M)] [UNSIGNED] [ZEROFILL] M默认为6 |
mediumint |
MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL] M默认为9 |
int |
INT[(M)] [UNSIGNED] [ZEROFILL] M默认为11 |
bigint |
BIGINT[(M)] [UNSIGNED] [ZEROFILL] M默认为20 |
注:这里的M代表的并不是存储在数据库中的具体的长度,而是指明int的最小显示位数,并且该值只有在指明了zerofill之后才会生效。
mysql> create table t (t int(3)); Query OK, 0 rows affected (0.02 sec) mysql> insert into t values(11),(111),(1111); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from t; +------+ | t | +------+ | 11 | | 111 | | 1111 | +------+ 3 rows in set (0.00 sec) mysql> alter table t change t t int(3) zerofill; Query OK, 3 rows affected (0.06 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from t; +------+ | t | +------+ | 011 | | 111 | | 1111 | +------+ 3 rows in set (0.00 sec)
标签:values blog table height var 并且 val 声明 alter
原文地址:http://www.cnblogs.com/jade640/p/7169651.html