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)
Asked
Active
Viewed 38 times
0
-
Oracle doesn't have`auto_increment`. Use `generated always|by default as identity` – astentx Aug 24 '22 at 20:33
2 Answers
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.

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