Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL to view Table Relationships?
Hi, Scott.
If in fact the tables reside in your user's schema, you should at least be getting rows returned from the select you've included in your post. Are you sure the user name shouldn't be capitalized? Maybe you should try " where owner = 'NEW_DEMO' ". Or, you could just select from user_tab_columns when logged in as the new_demo user.
Anyways, once you get that working, you'll realize that this does not give you the information you are after, since the %tab_column views just list columns in tables with no relationship info. Instead, try selecting from all_constraints where constraint_type = 'R' and owner = 'NEW_DEMO'. If you need to get more detailed than that, you can do a join with all_cons_columns and all_tab_columns.
Hth,
-Jeff Guttadauro
On 22 Jul 1999 11:50:42 -0400, "Scott Murray" <smurray_at_officecomp.com> wrote:
>I am stumped trying to display the relationships between tables (i.e.,
>which tables have foreign keys to which tables).
>
>I've tried using:
>
>select * from all_tab_columns
>where owner = 'new_demo' [that's my user name]
>;
>
>and some similar commands, but I keep getting no records found.
>
>Can anyone help me out?
>
>Thanks in advance,
>
>Scott Murray
>smurray_at_officecomp.com
Received on Thu Jul 22 1999 - 11:37:04 CDT
![]() |
![]() |