List of Constraints from MySQL Database

前端 未结 4 764
猫巷女王i
猫巷女王i 2020-12-02 05:37

How do I get a list of all constraints from a particular database?

4条回答
  •  一整个雨季
    2020-12-02 06:14

    Great answer by @Senseful.

    I am presenting modified query for those who are only looking for list of constraint names (and not other details/columns):

    SELECT DISTINCT(constraint_name) 
    FROM information_schema.table_constraints 
    WHERE constraint_schema = 'YOUR_DB' 
    ORDER BY constraint_name ASC;
    

提交回复
热议问题