In Oracle, you can use the select statement to query the foreign key of the table, the syntax is "select * from user_cons_columns cl where cl.constraint_name = foreign key name;".
The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.
Foreign key is the relationship between tables. For example, an instance of one table refers to a column of another table. Let's start with a simple example to understand the concept clearly.
Query the foreign key of the table (including the name, the table name of the reference table and the corresponding key name, the following is a multi-step query)
Query table information
select * from user_constraints c where c.constraint_type = 'R' and c.table_name = 要查询的表;
Query the column name of the foreign key constraint
select * from user_cons_columns cl where cl.constraint_name = 外键名称;
Query the column name of the key of the reference table
select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名;
Recommended tutorial: "Oracle Tutorial"
The above is the detailed content of How to query the foreign keys of a table in Oracle. For more information, please follow other related articles on the PHP Chinese website!