DB2 PrimaryKey 主键操作SQL总结

Categories: Database; Tagged with: ; @ October 5th, 2010 21:06

1. ADD PRIMARY KEY 增加主键

ALTER TABLE EMPLOYEE ADD PRIMARY KEY (EMPLOYEE_ID, ORGNO);

2. DROP PRIMARY KEY 删除主键

ALTER TABLE EMPLOYEE DROP PRIMARY KEY

3. SET AUTOINCREMENT 设置自增

ALTER TABLE TB2 ALTER COLUMN ID (DROP DEFAULT) SET GENERATED AS IDENTITY ( START WITH 0 INCREMENT BY 1 NO CACHE ) ;

DROP DEFATULT: 如果之前已有DEFAULT值时使用.

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.