SQL error - incorrect table definition; there can only be one automatic column

What is wrong with this SQL, ->); ERROR 1075 (42000): Incorrect table definition; there can only be one automatic column

SQL

CREATE TABLE TABLENAME12 ( TAB_ID INT NOT NULL AUTO_INCREMENT, NAME_FIRST NVARCHAR(200), TYPE NVARCHAR(200) ); 

I am using mysql, how can I solve this. I am trying to create a table. and i get this error

+6
source share
3 answers

The simulated result you get with

 CREATE TABLE TABLENAME12 ( TAB_ID INT NOT NULL AUTO_INCREMENT, NAME_FIRST NVARCHAR(200), TYPE NVARCHAR(200), PRIMARY KEY( TAB_ID ) ); 

It can also be used with another db like mysql, besides defining int and nvarchar types. if you use varchar and integer, you are compatible with postgresql instead.

+3
source

You must specify the AUTO_INCREMENT column as a PRIMARY KEY try:

 CREATE TABLE TABLENAME12 ( TAB_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, NAME_FIRST NVARCHAR(200), TYPE NVARCHAR(200) ); 
+7
source

As the error says.

 "Incorrect table definition; there can be only one auto column and it must be defined as a key" 

http://sqlfiddle.com/#!2/7e064

Add a primary key in the auto_increment column.

 CREATE TABLE TABLENAME12 ( TAB_ID INT NOT NULL AUTO_INCREMENT, NAME_FIRST NVARCHAR(200), TYPE NVARCHAR(200), PRIMARY KEY (TAB_ID) ); 
+6
source

Source: https://habr.com/ru/post/921202/


All Articles