oracle删除主键查看主键约束及创建联合主键

1,主键的删除

ALTER TABLE TABLENAME DROP PRIMARY_KEY
执行上面的SQL可以删除主键;如果不成功可以用
ALTER TABLE TABLENAME DROP CONSTRAINTS COLUMN CASCADE; –删除约束
ALTER TABLE TABLENAME DISABLE PRIMARY_COLUMN ; –设置被设置为主键的列为无效
DROP INDEX INDEX_NAME; –删除主键索引

2,查看主键约束

SELECT * FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE='P' AND TABLE_NAME='你要查看的表名' AND OWNER=USER

3,创建联合主键

ALTER TABLE ADD CONSTRAINTS ‘约束名’ PRIMARY KEY (COLUMN,COLUMN,…);


数据运维技术 » oracle删除主键查看主键约束及创建联合主键