Oracle primary key deletion, joint primary key creation, oracle primary key
1. Delete the primary key alter table tablename drop PRIMARY_KEY execute the preceding SQL statement to delete the primary key; if it fails, use ALTER TABLE TABLENAME DROP CONSTRAINTS COLUMN CASCADE; -- delete the constraint ALTER TABLE TABLENAME DISABLE PRIMARY_COLUMN; -- The column set as the primary key is invalid drop index INDEX_NAME; -- delete the primary key INDEX
2. view the primary key constraint SELECT * FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'p' AND TABLE_NAME = 'name of the table you want to view 'and owner = USER
3. Create the joint primary key alter table add constraints 'constraint name' primary key (COLUMN, COLUMN ,...);
Oracle joint primary key Creation
Alter table xxx add constraints xxx_pk primary key (c1, c2, c3, c4, c5 ....);
Oracle uses an SQL script to delete the original primary key and then create a new primary key. The new primary key is added based on the original primary key.
Delete an existing primary key first:
Alter table devuser. tb_term_info drop primary key;
Add another field:
Alter table devuser. tb_term_info add column attr_fg;
Re-create a primary key:
Alter table devuser. tb_term_info
Add primary key (time, numer_sq, system_id, system_type_id, attr_fg)
Using users
Tablespace IDX_TS_BUSIS_ONLINE
Pctfree 10
Initrans 2
Maxtrans 255
Storage
(
Initial 64 K
Minextents 1
Maxextents unlimited
);
Note that you must have the corresponding operation permissions on the devuser User table.