Home » SQL & PL/SQL » SQL & PL/SQL » Primary key & Column name
Primary key & Column name [message #37428] Thu, 07 February 2002 03:36 Go to next message
Hao
Messages: 4
Registered: December 2000
Junior Member
Hi All;

How can I find out all the columns make up the primary key for a given table?? And all the column names for a particular table?

Thanks
Hao
Re: Primary key & Column name [message #37429 is a reply to message #37428] Thu, 07 February 2002 04:41 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
1)
select column_name from all_cons_columns A,ALL_CONSTRAINTS B
where A.constraint_name=b.constraint_name and
b.table_name=upper('&tablename') AND CONSTRAINT_TYPE='P' ORDER BY POSITION

2) select column_name from all_tab_columns
where table_name=upper('&TABLENAME');
Re: Primary key & Column name [message #37431 is a reply to message #37428] Thu, 07 February 2002 05:37 Go to previous message
Hao
Messages: 4
Registered: December 2000
Junior Member
Thanks Suresh.
Previous Topic: Indexes
Next Topic: I want to load data from 3 tables in schema1 into a table in schema2 using a CURSOR..
Goto Forum:
  


Current Time: Fri Apr 19 07:09:52 CDT 2024