can some one help me on constraints
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: can some one help me on constraints

  1. #1
    Join Date
    Apr 2002
    Posts
    1

    Cool

    Hi ,

    have a doubt in constraints ie referential, foreign key.


    now i create a test table

    CREATE TABLE TEST (COL1 VARCHAR2(10) PRIMARY KEY);

    CREATE TABLE TEST1 (COL1 VARCHAR2(10) PRIMARY KEY,
    COL2 VARCHAR2(10) );


    CREATE TABLE TEST2(COL_1 REFERENCES TEST1(COL1),
    COL_2 VARCHAR2(10));

    WHICH SYSTEM TABLE WILL YOU QUEERY TO
    FIND OUT WHICH TABLE IS COL_1 OF TEST2 WILL REFERENCE TO .

    THE TABLE USER_CONS_COLUMNS AND USER_CONSTRAINTS GIVES THE CONSTRAINT NAME AND CONSTRAINT TYPE BUT WILL NOT GIVE WHICH TABLE IS
    THIS COLUMN COL_1 REFFERING TO

    CAN SOME ONE HELP ME OUT





  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    Hi,
    it's the USER_CONSTRAINTS.R_CONSTRAINT_NAME column.
    Foreign keys reference primary keys, not columns.
    Ales

  3. #3
    Hi,

    try out

    select table_name from user_constraints where constraint_name in (select r_constraint_name from user_constraints)
    /

    This should give you a list of table names your referential constraint is looking at! The logic behind this is the fact that the foreign key looks at the primary key of another table so there should be a valid record of that in the same user_constraints table!

    Thanks,
    have a nice day,
    -Shyami

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