Skip to main content

Get all Foreign key relationship with a table and its column

To get all the Foreign key referenced table and its column, use below query in MySQL.

            select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name from information_schema.key_column_usage where referenced_table_schema = 'dbName' and referenced_table_name = 'tableName' and referenced_column_name = 'columnName';

Comments

Popular posts from this blog

Get all constraints in Oracle

 To get all the constraints created in Oracle database, use below query.              SELECT * FROM USER_CONSTRAINTS; If you want to get the constraints  created for a particular user then use below SQL query.              SELECT   *   FROM  USER_CONSTRAINTS where owner = 'userName';