Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    63

    Question Unanswered: Finding referential constraints

    Hi,

    can i get DB2 equivalent of this oracle Query.

    this is to get all foreign key constraints which are dependent on table 'ABC'

    Select * from user_constraints
    where R_constraint_name=( select constraint_name from user_constraints
    where constraint_type='P' and table_name='ABC')


    And also where can we find a list of all constraints under a schema ?

    Thx
    Mohd

  2. #2
    Join Date
    Jan 2005
    Posts
    191
    select ... from syscat.references where reftabname = 'ABC'
    (don't know enough O to know exactly what you want. You might also need a join onto syscat.keycoluse.

    select ... from syscat.colchecks where tabschema = 'AAAA'

    James Campbell

  3. #3
    Join Date
    Jul 2003
    Posts
    63
    Thx James.
    Here is the exact SQL i was looking for

    select constname , tabschema, tabname,definer, reftabname,fk_colnames,pk_colnames
    from syscat.references where tabschema='DB2INST1' and reftabname='ABC'

    This will give all the tables with column names dependent on table 'ABC'


    Thx
    Mohd

Posting Permissions

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