Blog Home  Home Feed your aggregator (RSS 2.0)  
The Johnnynine Weblog - September, 2006
A weblog by Johnny Hughes
 
 Friday, September 01, 2006
To create a primary key

ALTER TABLE <table_name> ADD CONSTRAINT <primary_key_constraint_name> PRIMARY KEY (<column_name>) USING INDEX

To drop a primary key:

ALTER TABLE <tablename> DROP PRIMARY KEY


To view all the indexed columns includin the primarky key columns:

SELECT * FROM user_ind_columns WHERE table_name='<tablename>' ORDER BY index_name, column_position


To view the constraint names on a table (including the primary key name):

SELECT * FROM user_constraints WHERE table_name = '<tablename>'


To view the constraint columns and constraint names on a table (including the primary key):

SELECT * FROM user_cons_columns WHERE table_name = '<tablename>'


Good oracle reference:
http://www.psoug.org/reference/constraints.html

Friday, September 01, 2006 4:49:57 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   Database | Oracle | Technical  | 
Copyright © 2008 Johnny Hughes. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.