0

This is what i have used to create new table

CREATE TABLE history(  
search_id int auto_increment=1000 primary key,  
f_name varchar(100) not null,  
f_lo varchar(300) not null,  
u_id varchar(50) not null unique,  
foreign key(u_id) references userinfo(user_id)  
);  

This is the error I'm facing

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1000 primary key, f_name varchar(100) not null, f_lo varchar(300) not null, u_i' at line 2

Refer this image :- https://i.stack.imgur.com/uXeoO.png

Ergest Basha
  • 7,870
  • 4
  • 8
  • 28

2 Answers2

0
CREATE TABLE history(
search_id int auto_increment primary key,
f_name varchar(100) not null,
f_lo varchar(300) not null,
u_id varchar(50) not null unique,
foreign key(u_id) references userinfo(user_id)
);

Try not to initialize auto increment

Once you create the above table you can alter it by:

ALTER TABLE history AUTO_INCREMENT = 1000;

link to refer

0

AUTO_INCREMENT value is table option, not column option or default value. See CREATE TABLE Statement.

So

CREATE TABLE history(
    search_id int auto_increment primary key,
    f_name varchar(100) not null,
    f_lo varchar(300) not null,
    u_id varchar(50) not null unique,
    foreign key(u_id) references userinfo(user_id)
) AUTO_INCREMENT = 1000;
Akina
  • 39,301
  • 5
  • 14
  • 25