1.MySQL每张表只能有1个自增字段,这个自增字段即可作为主键,也可用作非主键使用,但是请注意将自增字段当做非主键使用时必须为其添加唯一索引,否则系统将会报错 )将自动增长字段设置为主键 CREATE TABLE t1 ( id INT auto_increment PRIMARY KEY, sid INT ); )将自动增长字段设置为非主键 CREATE TABLE t2 ( sid INT PRIMARY KEY, id INT auto_increment UNIQUE ); )将自动增
1,删除原有主键: ALTER TABLE `table_name` DROP `id`; 2,添加新主键字段: ALTER TABLE `table_name` ADD `id` INT NOT NULL FIRST; 3,设置新主键: ALTER TABLE `table_name` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT,ADD PRIMARY KEY(id);
create sequence SEQ_ERRORID minvalue 1 maxvalue 99999999 start with 1000 increment by 1 nocache order; create or replace trigger tri_ERRORINFO_ERRORID --触发器名称 before insert on REPORT_ERRORINFO_PDF --Test是表名 for each row declare nextid number; begin I