时间:2021-07-01 10:21:17 帮助过:2人阅读
格时加入:
create table table1(id int auto_increment primary key,...)
alter table table1 add id int auto_increment primary key 自增字段。一定要设置为primary key.
创建表格时加入:
CREATE TABLE `orders` ( `order_num` int(11) NOT NULL auto_increment, `order_date` datetime NOT NULL, `cust_id` int(11) NOT NULL, PRIMARY KEY (`order_num`), KEY `fk_orders_customers` (`cust_id`), CONSTRAINT `fk_orders_customers` FOREIGN KEY (`cust_id`) REFERENCES `customers` (`cust_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
创建表格后加入:
alter table users AUTO_INCREMENT=10000;
alter table users AUTO_INCREMENT=123456;
版权声明:本文博客原创文章。博客,未经同意,不得转载。
mysql增量ID启动值更改方法
标签: