bigint(10)和bigint(20)的区别

1、bigint(10)和bigint(20)的区别在于如果表定义加上zerofill后再客户端显示长度不同,如下:

 MariaDB [test]> create table test2 (id bigint(10) zerofill,   
 -> id1 bigint(20) zerofill);

MariaDB [test]> insert into test2 values(1,2);

MariaDB [test]> select * from test2;

id                   id1
0000000001 00000000000000000002

2、如果在创建bigint字段时,不指定长度,则默认长度为20,如下:

 

mysql> create table test3 (id bigint);

Query OK, 0 rows affected

mysql> show create table test3;

Table Create Table

test3 CREATE TABLE `test3` (  `id` bigint(20) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;

3、无论是bigint(10),还是bigint(20)均占用8个字节,int和tinyinit类型类似。

posted @ 2017-03-21 14:36  程序Dog-NO1  阅读(22875)  评论(0编辑  收藏  举报