Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: To know tables' columns in a database
Vince wrote:
> I recall what I try to get:
>
> For each key column, I would like to get a row with
> - table name of this column
> - column name
> - key name ie constraint name
> - position within the key
> - a type = 'Primary', 'Secondary' or 'Foreign'
> - a target table only for foreign keys
> - a target column
>
>> You really need to get familiar with these views if you want to do >> anything useful around Oracle in the long run.
Start with:
SELECT This.constraint_name, This.constrainttype,
This.table_name, That.table_name FROM all_constraints This, all_cons_columns Got,
all_constraints That
WHERE This.constraint_name = Got.constraint_name
AND This.r_constraint_name = That.constraint_name (+)
I hope you post the rest, including an explanation about how/why it works. There are many students who ask this on a regular basis - put the answer into the archives and tey will likely appreciate it (if tey bother to search).
/Hans Received on Fri Feb 20 2004 - 10:30:34 CST
![]() |
![]() |