Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    17

    Unanswered: DB2 Help to write sql

    Hi All,

    Could some one please help to write the sql code for the below:

    1. Find the percentage of foreign keys with no matching indexes
    2. Container name includes table space name

    In db2.

    I don't know could some one please help

    Thanks for your help in advance
    Last edited by iam_hari; 11-01-12 at 05:11.

  2. #2
    Join Date
    Mar 2003
    Posts
    280
    Quote Originally Posted by iam_hari View Post
    Hi All,

    Could some one please help to write the sql code for the below:

    1. Find the percentage of foreign keys with no matching indexes
    2. Container name includes table space name

    In db2.

    Thanks for your help in advance
    Surely you have some idea, what did you try and why did it not work?

  3. #3
    Join Date
    Jul 2011
    Posts
    17
    I did get till here - got an idea to extract foreign keys from all the tables

    select substr(tabname,1,20) table_name,substr(constname,1,20) fk_name,substr(REFTABNAME,1,12) parent_table,substr(refkeyname,1,20) pk_orig_table,fk_colnames from syscat.references

    I read about matching index, however I am largely unclear how to look for no matching index in the above query.

    Any ideas or pointers are appreciated.

    Thanks

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I think you will need to look for indexes whose columns match those of the foreign key.
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

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