Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2003
    Posts
    87

    Unanswered: query to retrieve primary key

    i wanna know the query to retrieve primary key of a table.

    expecting reply.

  2. #2
    Join Date
    Oct 2003
    Posts
    87

    The "Magic Word" is PLEASE

    Join DBA_CONSTRAINTS to DBA_CONS_COLUMNS where CONSTRAINT_TYPE = P and CONSTRAINT_NAMEs are =
    Oracle - DB2 - MS Access -

  3. #3
    Join Date
    Nov 2003
    Location
    Berlin, Germany
    Posts
    6

    Re: query to retrieve primary key

    Maybe this will do it:

    SELECT column_name
    FROM dba_constraints a,dba_cons_columns b
    WHERE a.table_name='your_table'
    AND a.constraint_name=b.constraint_name
    AND a.constraint_type ='P';

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: The "Magic Word" is PLEASE

    Yes, what is this "expecting reply" phrase meant to convey? Is it a polite expression in some countries? Because it comes across as somewhat impolite to me, like: "I demand that you reply to this". As a customer, I might put that on a message to a supplier who had failed to respond in a timely manner before.

    This is probably all just a cultural differences issue ;o)

  5. #5
    Join Date
    Sep 2003
    Posts
    156

    Re: The "Magic Word" is PLEASE

    Originally posted by andrewst
    Yes, what is this "expecting reply" phrase meant to convey? Is it a polite expression in some countries? Because it comes across as somewhat impolite to me, like: "I demand that you reply to this". As a customer, I might put that on a message to a supplier who had failed to respond in a timely manner before.

    This is probably all just a cultural differences issue ;o)
    know what i mean? now get that reply, chop chop!
    rgs,

    Ghostman

  6. #6
    Join Date
    Nov 2003
    Location
    Bangalore, INDIA
    Posts
    333

    Re: query to retrieve primary key

    Hi,

    U can use
    USER_CONSTRAINTS table to view the constraints on ur tables.
    ALL_CONSTRAINTS to view the constraints on all the objects that r
    accessible to all the users.
    DBA_CONSTRAINTS to view constraints on all the objects in the
    database.

    U can also use
    USER_CONS_COLUMNS
    ALL_CONS_COLUMNS
    DBA_CONS_COLUMNS

    to view the constraints on the columns.
    SATHISH .

  7. #7
    Join Date
    Nov 2003
    Posts
    87

    thanks

    Thanks a lot for all the members who replied for my query.

    The following query helped me to get the required output.


    select column_name from all_cons_columns where
    table_name = 'TABLE_NAME';

  8. #8
    Join Date
    Oct 2003
    Posts
    87

    Re: thanks

    Originally posted by raseena
    Thanks a lot for all the members who replied for my query.

    The following query helped me to get the required output.


    select column_name from all_cons_columns where
    table_name = 'TABLE_NAME';
    That query doesn't retrieve just the PK. TeeWan had it right:

    SELECT column_name
    FROM dba_constraints a,dba_cons_columns b
    WHERE a.table_name='your_table'
    AND a.constraint_name=b.constraint_name
    AND a.constraint_type ='P';
    Oracle - DB2 - MS Access -

Posting Permissions

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