Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

to know the foreign keys

mysql> SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME 
     > FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE 
     > WHERE REFERENCED_TABLE_SCHEMA IS NOT NULL;
+--------------+---------------+-------------+-----------------+
| TABLE_SCHEMA | TABLE_NAME    | COLUMN_NAME | CONSTRAINT_NAME |
+--------------+---------------+-------------+-----------------+
| fk1          | myuser        | myuser_id   | f               |
| fk1          | product_order | customer_id | f2              |
| fk1          | product_order | product_id  | f1              |
+--------------+---------------+-------------+-----------------+
3 rows in set (0.01 sec)
Source by www.cs.usfca.edu #
 
PREVIOUS NEXT
Tagged: #foreign #keys
ADD COMMENT
Topic
Name
9+4 =