Oracle query - increase - delete - modify the primary key

The operation of Oracle primary key table, there are four types: query, add, modify, delete

1, the primary key query

/ * Query the constraints that exist in a table * / 
the SELECT  *  from USER_CONSTRAINTS the WHERE table_name = ' table name in uppercase ' ; 
query results show the type of constraint, the constraint name does not appear on the constraints which field 
/ * query fields in a table constraint * / SELECT * from USER_CONS_COLUMNS WHERE table_name = ' table uppercase ' ; search-result display constraint names, field names, does not show the constraint type
/ * query constraint primary key of a table * / SELECT A.column_name, A.constraint_name from USER_CONS_COLUMNS a , B USER_CONSTRAINTS WHERE A.constraint_name =B.constraint_name and A.table_name = ' table uppercase ' and B.constraint_type = ' P ' ; search-result display column names, constraint name. ' P ' represents a Primary Key , ' C ' represents a check, where constraint_type = ' P '

2, to increase the master key

ALTER  Table table the Add  constraint primary key name Primary  Key (column names);

3 , delete the primary key

/ * Primary key can be obtained at the query * / 
the ALTER  the Table table name drop  constraint A primary key

4, modify the primary key

oracle can not directly modify the primary key, and then increase by deleting the existing primary key to achieve the purpose of modification

Guess you like

Origin www.cnblogs.com/handhead/p/11617934.html