【简记】mysql alter主键类型int->bigint

阅读 45

2022-04-29

alter

命令:

alter table `test` modify column `id` bigint(20) NOT NULL;
alter table `test1` modify column `id` bigint(20) NOT NULL;
alter table `test2` modify column `id` bigint(20) NOT NULL;

修改前:

desc test;
+-------------------------+--------------+------+-----+---------+----------------+
| Field                   | Type         | Null | Key | Default | Extra          |
+-------------------------+--------------+------+-----+---------+----------------+
| id                      | int(11)      | NO   | PRI | NULL    | auto_increment |
| name                    | varchar(255) | NO   | UNI | NULL    |                |

修改后:

desc test;
+-------------------------+--------------+------+-----+---------+-------+
| Field                   | Type         | Null | Key | Default | Extra |
+-------------------------+--------------+------+-----+---------+-------+
| id                      | bigint(20)   | NO   | PRI | NULL    |       |
| name                    | varchar(255) | NO   | UNI | NULL    |       |

精彩评论(0)

0 0 举报