bigint如何自增_mysql数据库中记录条数超过了bigint的最大长度,自增编号会如何样...

mysql数据库中记录条数超过了bigint的最大长度,自增编号会怎么样

mysql数据库中的整型类型可以自增编号,其中bigint表示的长度最大,但是如果数据库中的记录条数超过了bigint的最大值会怎么样呢,会出现无法写入数据库的情况吗? 或者说出现这种情况该怎么解决。

------解决方案--------------------

以下是我的测试结果,供参考:

mysql> create table t(id bigint unsigned auto_increment primary key, col2 int);

Query OK, 0 rows affected (0.00 sec)

mysql> insert into t values(18446744073709551613,1);

Query OK, 1 row affected (0.00 sec)

mysql> insert into t values(null, 1);

Query OK, 1 row affected (0.00 sec)

mysql> insert into t values(null, 1);

Query OK, 1 row affected (0.00 sec)

mysql> insert into t values(null, 1);

Query OK, 1 row affected (0.00 sec)

mysql> insert into t values(null, 1);

Query OK, 1 row affected (0.00 sec)

mysql> select * from t;

+----------------------+------+

| id | col2 |

+----------------------+------+

| 1 | 1 |

| 2 | 1 |

| 3 | 1 |

| 4 | 1 |

| 18446744073709551613 | 1 |

+----------------------+------+

5 rows in set (0.00 sec)

mysql> show variables like '%vers%';

+-------------------------+-----------------------+

| Variable_name | Value |

+-------------------------+-----------------------+

| protocol_version | 10 |

| version | 5.0.9-beta-nt |

| version_comment | Official MySQL binary |

| version_compile_machine | ia32 |

| version_compile_os | Win32 |

+-------------------------+-----------------------+

5 rows in set (0.00 sec)

mysql>

微信 赏一包辣条吧~

支付宝 赏一听可乐吧~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值