0

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)

Andy Lester
  • 91,102
  • 13
  • 100
  • 152

2 Answers2

1

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.

Littlefoot
  • 131,892
  • 15
  • 35
  • 57
0

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?

Andy Lester
  • 91,102
  • 13
  • 100
  • 152