MySQL SHOW CREATE TABLE statement will provide us the constraints applied to a particular table along with some other details about that table. Its syntax would be as follows −
Syntax
SHOW CREATE TABLE table_name;
Here table_name is the name of the table on which we want to see the constraints.
Example
In this example we are getting the detail of the table named ‘employees’ −
mysql> Show Create table employees\G *************************** 1. row *************************** Table: employees Create Table: CREATE TABLE `employees` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(35) DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec)
The above result set shows that there is a PRIMARY KEY constraint on column ’id’ in table ‘employees’.