show PK,FK
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: show PK,FK

  1. #1
    Join Date
    Dec 2002
    Posts
    4

    show PK,FK

    I created a table with multiple and primary keys. How can i view my primary and foreign keys in a description of a table..?

  2. #2
    Join Date
    Feb 2001
    Posts
    180
    View here:
    select * from sys.all_constraints
    where ...
    Regards
    Ben de Boer

  3. #3
    Join Date
    Nov 2000
    Location
    Israel
    Posts
    268
    Hi,
    if by description you mean to use the describe command, then you can't.

    you can use this query:
    -----------------------------------------------
    accept tab_name prompt "Enter Table Name: "
    select table_name, constraint_name, constraint_type
    from user_constraints
    where constraint_type in ('P','R')
    where table_name = '&tab_name';
    -----------------------------------------------

    If you want to know the columns involved in any constraint
    simply query the user_cons_columns:
    -----------------------------------------------
    select constraint_name,column_name from user_cons_columns
    where constraint_name = 'constraint_name'
    order by constraint_name,column_name,position;
    -----------------------------------------------

    Cheers,
    R.
    It is better to ask and appear ignorant, than to remain silent and remain ignorant.

    Oracle OCP DBA 9i,
    C++, Java developer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width