Re: How do I view PK and FK Constraints?

From: <jl34778_at_corp02.d51.lilly.com>
Date: 29 Nov 94 09:22:18 EST
Message-ID: <1994Nov29.092218.1_at_corp02.d51.lilly.com>


In article <Roberts_D-281194082234_at_riversend.bms.com>, Roberts_D_at_MSMAIL.BMS.COM (Dan Roberts) writes:
> After I have created a table in my Oracle database..How can I view which
> attributes I have assigned as Primary Keys and such. When I do a describe
> either tablename or catalog I really don't get the output I am looking
> for..Thanks.>>Dan
>
> --
> Dan Roberts
> BRISTOL-MYERS SQUIBB PHARM. RES. CENTER "Nature is last at Bats"
> PRINCETON, NEW JERSEY U.S.A. PLANET EARTH, MILKY-WAY GALAXY
> <<<<INTERNET ADDRESS>>>>Roberts_D_at_MSMAIL.BMS.COM

You need to look at USER_CONSTRAINTS and USER_CONS_COLUMNS. For example, this statement lists your primary key constraints and their columns.

break on table_name on constraint_name

select a.table_name, a.constraint_name, b.column_name from user_constraints a, user_cons_columns b where a.constraint_name = b.constraint_name   and constraint_type ='P'
order by a.table_name, a.constraint_name,b.position;

-- 
Bob Swisshelm                | swisshelm_at_Lilly.com     | 317 276 5472
Eli Lilly and Company        | Lilly Corporate Center  | Indianapolis, IN 46285
Received on Tue Nov 29 1994 - 15:22:18 CET

Original text of this message