1.查看所有约束
java
SELECT
CONSTRAINT_NAME,
TABLE_NAME,
CONSTRAINT_TYPE
FROM
information_schema.TABLE_CONSTRAINTS
WHERE
TABLE_NAME = '表名字';
2.删除约束
java
ALTER TABLE bus_qualification DROP INDEX unique_item_name;
3.添加约束
java
ALTER TABLE bus_qualification ADD UNIQUE KEY unique_item_name_company (item_name, item_company);
4.查看具体约束
java
SELECT
COLUMN_NAME,
CONSTRAINT_NAME
FROM
information_schema.KEY_COLUMN_USAGE
WHERE
TABLE_NAME = '表名';