ALTER TABLE EMPLOYEE ADD PRIMARY KEY (EMPLOYEE_ID, ORGNO);
ALTER TABLE EMPLOYEE DROP PRIMARY KEY
ALTER TABLE TB2 ALTER COLUMN ID (DROP DEFAULT) SET GENERATED AS IDENTITY ( START WITH 0 INCREMENT BY 1 NO CACHE ) ;
DROP DEFATULT: 如果之前已有DEFAULT值时使用.
ALTER TABLE TABLE2 DROP PRIMARY KEY
ALTER TABLE TABLE2 ADD ID2 INTEGER NOT NULL DEFAULT 1;
ALTER TABLE TABLE2 ADD PRIMARY KEY(ID2);
See: http://bytes.com/topic/db2/answers/670160-how-change-primary-key-already-existing-table
SQL:
SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR NOT LIKE ‘SYS%’ AND TBNAME = ‘TABLENAME‘ AND KEYSEQ > 0 ORDER BY KEYSEQ ASC;
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.