By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Names of columns with foreign keys

P: 1
Can anybody help me with such problem:
I need to get all columns names which have foreign key constraint.
For example:
I have table my_table with column my_column, and this column have foreign key constraint. What sql code will return me the name of this column if I know the name of it's foreign key constraint. In constraint_column_usage table we can find related table column name, but it is not exactly what i need.
I can't find table in information_schema which contains this information.

Thanks for any help.
Dec 7 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
Can anybody help me with such problem:
I need to get all columns names which have foreign key constraint.
For example:
I have table my_table with column my_column, and this column have foreign key constraint. What sql code will return me the name of this column if I know the name of it's foreign key constraint. In constraint_column_usage table we can find related table column name, but it is not exactly what i need.
I can't find table in information_schema which contains this information.

Thanks for any help.
Maybe like this
select column_name from information_schema.key_column_usage where table_name=your_table;
Dec 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.