```
SELECT CONCAT (table_name, '. ', column_name) as ' foreign key ',
Concat (Referenced_table_name, '. ', referenced_column_name) as ' references '
From Information_schema.key_column_usage
WHERE table_schema = ' $databasename '
And Referenced_table_name is not NULL;
```
Where ' $databasename ' is replaced by the name of the database you want to query.
```
mysql> SHOW CREATE TABLE mk_big_sent_visitor\g
1. Row ***************************
Table:mk_big_sent_visitor
Create table:create Table ' Mk_big_sent_visitor ' (
' id ' int (one) not NULL auto_increment,
' mk_big_sent_id ' int (one) is not NULL,
' customer_id ' int (one) is not NULL,
PRIMARY KEY (' id '),
KEY ' Fk_mk_big_sent_visitor_mk_big_sent1_idx ' (' mk_big_sent_id '),
KEY ' Fk_mk_big_sent_visitor_customer1_idx ' (' customer_id '),
CONSTRAINT ' Fk_mk_big_sent_visitor_customer1 ' FOREIGN KEY (' customer_id ') REFERENCES ' customer ' (' id ') on DELETE NO actio N on UPDATE NO ACTION,
CONSTRAINT ' Fk_mk_big_sent_visitor_mk_big_sent1 ' FOREIGN KEY (' mk_big_sent_id ') REFERENCES ' mk_big_sent ' (' ID ') on DELETE no action on UPDATE no action
) Engine=innodb DEFAULT Charset=utf8 comment= "
1 row in Set (0.00 sec)
```
To delete a foreign key:
```
ALTER TABLE mk_prize DROP FOREIGN KEY fk_think_mk_prize_shopweb1,
DROP FOREIGN KEY fk_mk_big_sent_visitor_mk_big_sent1;
```
Foreign key Query and delete