java - create table user("user_id int auto_increment"); not working in derby (embedded database) -
i new in derby library. why got error when use auto_increment in query?
here java code
this.conn.createstatement().execute(create table user("user_id int auto_increment, primary key(user_id))");
i tried in mysql server , works in derby got error
java.sql.sqlsyntaxerrorexception: syntax error: encountered "auto_increment" @ line 1
why got error?
derby not have auto_increment keyword. in derby need use identity columns implement auto increment behaviour
for example
create table students ( id integer not null generated identity (start 1, increment 1), name varchar(24) not null, address varchar(1024), constraint primary_key primary key (id) ) ;
above statement create student table id auto increment column , primary key well.
hope helps
Comments
Post a Comment