Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to find out the relationship of tables

Re: How to find out the relationship of tables

From: Paul Koppens <pkoppens_at_dstm.nl>
Date: 22 Sep 1998 20:33:51 GMT
Message-ID: <01bde668$5692f220$073ff161@pko.ntdom1>


Dear k,

I suppose you could take a look at the USER_CONSTRAINTS and USER_CONS_COLUMNS data dictionary views. USER_CONSTRAINTS has a column CONSTRAINT_TYPE. If it contains a 'P', the constraint is a primary key constraint; in that case, other constraints (referential constraints: type 'R') may refer to that particular primary key constraint. If they do, R_CONSTRAINT_NAME contains the name of the primary key they refer to. Instead of referring to a primary key, a referential constraint may also use a unique key. For example, when table A has a primary key constraint named PRIMARY_A, table B could have a referential constraint named REFERENTIAL_BA, referring to PRIMARY_A. USER_CONSTRAINTS would list both constraints; the types would be 'P', and 'R', respectively; and REFERENTIAL_BA would have PRIMARY_A in R_CONSTRAINT_NAME. USER_CONS_COLUMNS will give you the names of the columns involved. You can query these views using SQL*Plus. If you have Oracle Designer 2000 available, it will provide you with some nice tools to reverse engineer your database and create an ER diagram. Of course, all of this assumes that the relationships in your database have been properly defined with constraints; otherwise, there is no way of finding them out.

Good Luck,

Paul.

k <k_at_k.com> wrote in article <3607EFF1.D5978401_at_k.com>...
> Hi,
>
> I have another question. Is there a way to find out the relationship
> between the tables of a Database. If yes, how to do it. Thanks for any
> help.
>
> Note: OS is UNIX, ORACLE 7.3
>
> kedda.
>
>
>
>
Received on Tue Sep 22 1998 - 15:33:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US