List of constraints in the database
P粉752826008
P粉752826008 2023-08-22 15:07:48
0
1
463
<p>How to get a list of all constraints from a MySQL database? </p>
P粉752826008
P粉752826008

reply all(1)
P粉327903045

Use information_schema.table_constraints table to get the name of the constraints defined on each table:

select *
from information_schema.table_constraints
where constraint_schema = 'YOUR_DB'

Use information_schema.key_column_usage table to obtain the fields in these constraints:

select *
from information_schema.key_column_usage
where constraint_schema = 'YOUR_DB'

If you want to discuss foreign key constraints, use information_schema.referential_constraints:

select *
from information_schema.referential_constraints
where constraint_schema = 'YOUR_DB'
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!