Add PRIMARY KEY or UNIQUE directly to the end of the column definition.
mysql>
mysql> CREATE TABLE t
-> (
-> id INT NOT NULL PRIMARY KEY,
-> name CHAR(30) NOT NULL
-> );
mysql>
mysql> drop table t;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> CREATE TABLE t
-> (
-> id INT NOT NULL UNIQUE,
-> name CHAR(30) NOT NULL
-> );
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> drop table t;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category