Dav*_*ave 68
select distinct CONSTRAINT_NAME
from information_schema.TABLE_CONSTRAINTS
where table_name = 'table_name' and constraint_type = 'UNIQUE';
Run Code Online (Sandbox Code Playgroud)
use*_*345 12
这不会产生优雅的输出,但很容易记住:
SHOW CREATE TABLE table_name;
Run Code Online (Sandbox Code Playgroud)
select distinct CONSTRAINT_NAME
from information_schema.TABLE_CONSTRAINTS
where CONSTRAINT_SCHEMA = 'mysql'
Run Code Online (Sandbox Code Playgroud)