Thunder Thunder - 6 months ago 14
SQL Question

autoincrement in access sql is not working

How can I create a table with autoincrement in access. Here is what I have been doing but not working.

CREATE TABLE People_User_Master(
Id INTEGER primary key AUTOINCREMENT,
Name varchar(50),
LastName varchar(50),
Userid varchar(50) unique,
Email varchar(50),
Phone varchar(50),
Pw varchar(50),
fk_Group int,
Address varchar(150)
)

Lex Lex
Answer

Try adding the constraint at the end

CREATE TABLE People_User_Master(   
Id AUTOINCREMENT 
  , Name varchar(50)   
, LastName varchar(50)   
, Userid varchar(50) unique   
, Email varchar(50)   
, Phone varchar(50)   
, Pw varchar(50)   
, fk_Group int   
, Address varchar(150)
, CONSTRAINT id_pk PRIMARY KEY(Id)

)

Updated to fit the actual answer (the definition of INTEGER on the AUTOINCREMENT column was not allowed). Leaving PRIMARY KEY at the same line as Id AUTOINCREMENT does work.

Comments