Home » RDBMS Server » Server Administration » how to find out primary key in a table.
how to find out primary key in a table. [message #373101] Tue, 27 March 2001 13:45 Go to next message
shreya
Messages: 15
Registered: March 2001
Junior Member
Hi,

I need all the columns except the primary key from a table.
Can somebody tell me how can i do this using sql.
If possible send me the sql query.

Thanks in advance,
Shashi.
Re: how to find out primary key in a table. [message #373133 is a reply to message #373101] Wed, 28 March 2001 16:25 Go to previous messageGo to next message
CHACKO
Messages: 11
Registered: March 2001
Junior Member
SELECT CONSTRAINT_NAME,CONSTRAINT_TYPE FROM USER_CONSTRAINTS
WHERE TABLE_NAME='EMP';
Re: how to find out primary key in a table. [message #373134 is a reply to message #373101] Wed, 28 March 2001 16:34 Go to previous messageGo to next message
samreen
Messages: 2
Registered: March 2001
Junior Member
Try this

select column_name from ALL_CONS_COLUMNS where Constraint_name=
(select constraint_name from user_constraints where table_name ='TABLE_NAME' and constraint_type='P')
Re: how to find out primary key in a table. [message #373136 is a reply to message #373101] Wed, 28 March 2001 17:31 Go to previous messageGo to next message
nobody
Messages: 5
Registered: February 2001
Junior Member
No Message Body
Re: how to find out primary key in a table. [message #373149 is a reply to message #373101] Thu, 29 March 2001 12:35 Go to previous messageGo to next message
shashi
Messages: 34
Registered: March 2001
Member
Thanks Very much Samreen & Siddarth.
It worked out.

Shashi.
how to find out foreign keys referencing primary key in a table. [message #373962 is a reply to message #373101] Fri, 18 May 2001 03:57 Go to previous message
Sachin Patil
Messages: 7
Registered: May 2001
Junior Member
How to find out foreign keys which references the primary key of another table.
Previous Topic: Fetch Time Too Long!!
Next Topic: ora-00020 exception...urgent
Goto Forum:
  


Current Time: Mon Dec 23 10:00:26 CST 2024