Amp787
Amp787

Reputation: 21

JDBC Auto Increment

I am trying to create table that has column that auto increments the user id column. When I use the below code I get this error:

Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis

String sql = "CREATE TABLE DBUSER("
            + "USER_ID NUMBER(5) NOT NULL AUTO_INCREMENT, "
            + "USERNAME VARCHAR(20) NOT NULL, "
            + "CREATED_BY VARCHAR(20) NOT NULL, "
            + "CREATED_DATE DATE NOT NULL, " + "PRIMARY KEY (USER_ID) "
            + ")";         Statement stmt;
stmt = connection.createStatement();
stmt.executeUpdate(sql);

Upvotes: 0

Views: 543

Answers (1)

Alex
Alex

Reputation: 21766

It should work if you remove the auto-increment

CREATE TABLE DBUSER(
       USER_ID NUMBER(5) NOT NULL, 
       USERNAME VARCHAR(20) NOT NULL, 
       CREATED_BY VARCHAR(20) NOT NULL, 
       CREATED_DATE DATE NOT NULL,  
       PRIMARY KEY (USER_ID) 
        )

Auto increment is not supported in Oracle

Upvotes: 1

Related Questions