oracle Delete Primary Key View Primary Key Constraints and Create Union Primary Key

  • 2021-12-11 19:23:25
  • OfStack

1. Deletion of primary key


ALTER TABLE TABLENAME DROP PRIMARY_KEY
 Execute the above SQL You can delete the primary key; If it doesn't work, you can use 
ALTER TABLE TABLENAME DROP CONSTRAINTS COLUMN CASCADE; -- Delete constraint 
ALTER TABLE TABLENAME DISABLE PRIMARY_COLUMN ; -- Column whose setting is set as primary key is invalid 
DROP INDEX INDEX_NAME; -- Delete primary key index 

2. View primary key constraints


SELECT * FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE='P' AND TABLE_NAME=' The name of the table you want to view ' AND OWNER=USER

3. Create a federated primary key


ALTER TABLE ADD CONSTRAINTS ' Constraint name ' PRIMARY KEY (COLUMN,COLUMN,...);

Related articles: