Please help me to create an IDENTITY column in MySQL
Hi,
You can create identity column as:
1: While creating a table-->
-
CREATE TABLE table_name
-
(
-
id INTEGER AUTO_INCREMENT PRIMARY KEY
-
)
-
The identity column needs to be specified as a key (PRIMARY or UNIQUE)
2: If the table already exists-->
-
ALTER TABLE table_name ADD COLUMN id INTEGER AUTO_INCREMENT UNIQUE KEY;
-
I hope this helps.
Regards,
Pradeep.