Say you have a table called MY_TABLE, and the primary key in that table is MY_COLUMN, the primary key name is PK_MY_TABLE.
Then you can say,
SELECT CONSTRAINT_NAME FROM USER_CONSTRAINS WHERE R_CONSTRAINT_NAME ='PK_MY_TABLE';
Now, if you do not know the primary key then you can query the foreign keys as follows
SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE R_CONSTRAINT_NAME IN (SELECT T1.INDEX_NAME FROM USER_IND_COLUMNS T1, USER_INDEXES T2 WHERE T1.INDEX_NAME =T2.INDEX_NAME AND T2.TABLE_NAME = 'MY_TABLE' AND T1.COLUMN_NAME = 'MY_COLUMN');
Dig Deeper on Using Oracle PL-SQL
Related Q&A from Azim Fahmi
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.