1

Possible Duplicate:
Create autoincrement key in Java DB using NetBeans IDE

I am trying to create a table in netbeans, using -

CREATE TABLE Persons (
    P_Id int NOT NULL AUTO_INCREMENT,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255),
    PRIMARY KEY (P_Id)
)

but am getting the following error -

Syntax error: Encountered "AUTO_INCREMENT" at line 3, column 19. Line 1, column 1

Community
  • 1
  • 1
SimplyJaymin
  • 444
  • 8
  • 17

1 Answers1

1

Try removing the underscore. I think you can also combine the primary key declaration with the column like the following:

CREATE TABLE Persons (
    P_Id integer primary key autoincrement,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255)
)
Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197