Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Getting Primary Key Info. for a table

Re: Getting Primary Key Info. for a table

From: Stephan Born <stephan.born_at_beusen.de>
Date: Mon, 28 Aug 2000 15:07:33 +0200
Message-ID: <39AA6415.7878ED84@beusen.de>

> soon as the user selects a table, I need to
> retrieve the primary key columns for that table.
>
> Any quick help or pointer are greatly appreciated.
>

Hello,

This statement will select for all tables the primary-keys which can be more than one for a table.

select

	uc.TABLE_NAME,
	ucc.COLUMN_NAME,
	ucc.POSITION,
	uc.STATUS
from 
	user_cons_columns ucc, 
	user_constraints uc
where 
	uc.constraint_type = 'P' and
	ucc.CONSTRAINT_NAME = uc.CONSTRAINT_NAME
order by
	ucc.TABLE_NAME,
	ucc.POSITION;

Hope this will help you,

Regards, Stephan

-- 
---------------------------------------------------------------
Dipl.-Inf. (FH) Stephan Born   | beusen Solutions GmbH
fon: +49 30 549932-0           | Landsberger Allee 392
fax: +49 30 549932-21          | 12681 Berlin
                               | Germany
---------------------------------------------------------------
       PGP-Key verfügbar       |      PGP-Key available
---------------------------------------------------------------
Received on Mon Aug 28 2000 - 08:07:33 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US