int类型测试,不能插入超过21亿条(2147483647)

mysql> show create procedure  proc_lie22;
+------------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| Procedure  | sql_mode               | Create Procedure                                                                                                                                                                    | character_set_client | collation_connection | Database Collation |
+------------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| proc_lie22 | NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`dball`@`localhost` PROCEDURE `proc_lie22`()
begin
DECLARE i INT DEFAULT 1;
WHILE i <= 2200000000 DO
insert into test.a (lie1) values (9);
SET i=i+1;
END WHILE;
END | utf8                 | utf8_general_ci      | utf8_general_ci    |
+------------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
1 row in set (0.02 sec)

mysql> show create table a;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| a     | CREATE TABLE `a` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `lie1` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3673265692 DEFAULT CHARSET=utf8 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> insert into a values(3673265692,3673265692);
Query OK, 1 row affected, 1 warning (0.00 sec)

| Table | Create Table                                                                                                                                                                 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| a     | CREATE TABLE `a` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `lie1` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3673265692 DEFAULT CHARSET=utf8 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> insert into a values(3673265692,3673265692);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-----------------------------------------------+
| Level   | Code | Message                                       |
+---------+------+-----------------------------------------------+
| Warning | 1264 | Out of range value for column 'lie1' at row 1 |
+---------+------+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from a where id=3673265692;
+------------+------------+
| id         | lie1       |
+------------+------------+
| 3673265692 | 2147483647 |
+------------+------------+
1 row in set (0.03 sec)

mysql> insert into a values(3673265693,3673265693);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql>
mysql> select * from a where id=3673265693;
+------------+------------+
| id         | lie1       |
+------------+------------+
| 3673265693 | 2147483647 |
+------------+------------+
1 row in set (0.00 sec)

mysql> show variables like "sql_mode";
+---------------+------------------------+
| Variable_name | Value                  |
+---------------+------------------------+
| sql_mode      | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+
1 row in set (0.00 sec)

  

 

 

 

posted on 2020-10-12 14:22  星期六男爵  阅读(303)  评论(0编辑  收藏  举报

导航