Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to check if a column is a foreign key? If yes, to which
SQL> SELECT c.constraint_name AS "Foreign Key",
2> p.constraint_name AS "Referenced Key", 3> p.constraint_type, 4> p.owner, 5> p.table_name 6> FROM dba_constraints c, dba_constraints p 7> WHERE c.owner=3D'SCOTT' 8> AND c.table_name=3D'EMPLOYEES' 9> AND c.constraint_type=3D'R'
Foreign Key Referenced Key C OWNER TABLE_NAME ------------ -------------- - ---------- ------------- EMP_DEPT_FK DEPT_PK P SCOTT DEPARTMENTS 1 row selected.
HTH,
Sandeep.
Riyadh, Saudi Arabia.
-----Original Message----- From: Libal, Ivo [SMTP:ivo.libal_at_knapp-systems.com] Sent: Tuesday, August 01, 2000 5:24 PM To: Multiple recipients of list ORACLE-L Subject: AW: How to check if a column is a foreign key? Ifyes, to which=20
Hi DBA_CONSTRAINTS DBA_CONS_COLUMNS This should help Ivo LibalReceived on Thu Aug 03 2000 - 04:44:59 CDT
> -----Urspr=FCngliche Nachricht-----
> Von: Dries Verachtert [SMTP:dries_at_ulyssis.org]
> Gesendet am: Dienstag, 1. August 2000 12:44
> An: Multiple recipients of list ORACLE-L
> Betreff: How to check if a column is a foreign key? If yes,
to which
> column
>=20
>=20
> Hello,
>=20
> I'm trying to make a servlet which produces a nice form to fill in
a new
> row
> of a table when you give it the name of the table as parameter.
Finding
> the
> names of all the columns in the table and their types seems easy,
but i
> can't
> find how to check if a column is a foreign key and to which column
in
> another table it points.=20
>=20
> Can someone give me some hints on which tables i need to use or if
you got
> lotsa time, a nice query wich gives me the columnname, the
columnname in
> the
> referenced table and the name of the referenced table of each
foreignkey
> in
> a table? :-)
> I'm trying to do this form java with jdbc to a oracle 8i 8.1.6.0
database.
> Jdbc has functions like getCrossReferences, getImportedKeys and
> getExportedKeys but that doesn't seem to give the correct output.
Any idea
> if these functions also should give the output i need?=20
>=20
> I've learned already a lot from this mailinglist. Is there
somewhere a faq
> of the most asked questions on this list?
>=20
> Thanx in advance,
> Dries Verachtert
>=20
> --=20
> Author: Dries Verachtert
> INET: dries_at_ulyssis.org
>=20
> Fat City Network Services -- (858) 538-5051 FAX: (858)
538-5051
> San Diego, California -- Public Internet access / Mailing
Lists
>
--------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and
in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You
may
> also send the HELP command for other information (like
subscribing). --=20 Author: Libal, Ivo INET: ivo.libal_at_knapp-systems.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may