Home > Software engineering >  (ORA-00907: missing right parenthesis) where is error in my code?
(ORA-00907: missing right parenthesis) where is error in my code?

Time:08-25

CREATE TABLE student( student_id int NOT NULL auto_increment, name VARCHAR(20) NOT NULL, major VARCHAR(20), PRIMARY KEY(student_id) ); why is it saying (ORA-00907: missing right parenthesis)

CodePudding user response:

If your Oracle database version supports it (12c or higher), use the identity column:

SQL> CREATE TABLE student
  2    (student_id int generated always as identity,
  3     name       VARCHAR(20) NOT NULL,
  4     major      VARCHAR(20),
  5     PRIMARY KEY(student_id)
  6    );

Table created.

SQL>

You don't have to specify not null constraint for primary key columns; they can't be null anyway.

CodePudding user response:

Oracle has no AUTO_INCREMENT. Take a look at this question for how to deal with that.

How to create id with AUTO_INCREMENT on Oracle?

  • Related