select* −>frominformation_schema.referential_constraints −>whereconstraint_schema='business';Berikut ialah output untuk memaparkan hanya kekangan kunci asing-+----- -"/> select* −>frominformation_schema.referential_constraints −>whereconstraint_schema='business';Berikut ialah output untuk memaparkan hanya kekangan kunci asing-+----- -">

Rumah  >  Artikel  >  pangkalan data  >  Dapatkan senarai kekangan kunci asing dalam MySQL

Dapatkan senarai kekangan kunci asing dalam MySQL

PHPz
PHPzke hadapan
2023-08-31 11:53:10737semak imbas

Dapatkan senarai kekangan kunci asing dalam MySQL

Katakan kita mempunyai "perniagaan" pangkalan data yang mengandungi berbilang jadual. Jika anda ingin memaparkan kekangan kunci asing sahaja, gunakan pertanyaan berikut -

mysql> select *
   −> from information_schema.referential_constraints
   −> where constraint_schema = 'business';

Di bawah ialah output untuk memaparkan hanya kekangan kunci asing -

+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME          | UNIQUE_CONSTRAINT_CATALOG | UNIQUE_CONSTRAINT_SCHEMA | UNIQUE_CONSTRAINT_NAME | MATCH_OPTION | UPDATE_RULE | DELETE_RULE | TABLE_NAME       | REFERENCED_TABLE_NAME |
+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+
| def                | business          | ConstChild               | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | childdemo         | parentdemo |
| def                | business          | ConstFK                  | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | tblf | tblp |
| def                | business          | constFKPK                | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | foreigntable      | primarytable1 |
| def                | business          | FKConst                  | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | foreigntabledemo | primarytabledemo |
| def                | business          | primarytable1demo_ibfk_1 | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | primarytable1demo| foreigntable1 |
| def                | business          | StudCollegeConst         | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION   | studentenrollment| college |
+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+
6 rows in set (0.07 sec)

Atas ialah kandungan terperinci Dapatkan senarai kekangan kunci asing dalam MySQL. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Artikel ini dikembalikan pada:tutorialspoint.com. Jika ada pelanggaran, sila hubungi admin@php.cn Padam