一、查看某数据库所有外键
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = "oeteach" /*数据库名称 */
AND REFERENCED_TABLE_NAME != ""
二、添加唯一性约束
alter table 表名 add unique(字段名1,字段名2,......);
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = "oeteach" /*数据库名称 */
AND REFERENCED_TABLE_NAME != ""
alter table 表名 add unique(字段名1,字段名2,......);