PHP小丑 发表于 2022-1-27 17:46:15

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=USER3,创建联合主键

ALTER TABLE ADD CONSTRAINTS '约束名' PRIMARY KEY (COLUMN,COLUMN,...);
https://www.uoften.com/dbs/oracle/20180415/73223.html
页: [1]
查看完整版本: oracle删除主键查看主键约束及创建联合主键