0

I am facing the issue while creating the Table in SQL,

CREATE TABLE Worker 
(
    WORKER_ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    FIRST_NAME CHAR(25),
    LAST_NAME CHAR(25),
    SALARY INT(15),
    JOINING_DATE DATETIME,
    DEPARTMENT CHAR(25)
);

Facing the Error

"ORA-00907: missing right parenthesis"

Can you please help with this. I have modified the query and re-run it various times still getting this error.

Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
  • 3
    Does this answer your question? [How to create id with AUTO\_INCREMENT on Oracle?](https://stackoverflow.com/questions/11296361/how-to-create-id-with-auto-increment-on-oracle). You appear to be using MySQL syntax in Oracle – Phil Nov 29 '19 at 04:40
  • AFIK Oracle up to 11 there may no concept like `AUTO_INCREMENT` You need to use `SEQUENCE`. So which version you use? – Divyesh patel Nov 29 '19 at 04:51
  • Unrelated to your problem, but: do not use the `char` data type it has a lot of disadvantages but no advantages whatsoever. –  Nov 29 '19 at 06:37

1 Answers1

1

AUTO_INCREMENT is not the keyword in Oracle and no such concept is available in oracle till oracle 12c.

In oracle 12c, The new concept is introduced, which is IDENTITY Columns.

Also, DATETIME is not a valid data type in oracle. see inline comments in the following example.

You can create the desired table as following in your case (Oracle 12 or higher):

SQL> CREATE TABLE Worker
  2  (
  3     WORKER_ID INT GENERATED BY DEFAULT ON NULL AS IDENTITY,
  4     FIRST_NAME CHAR(25),
  5     LAST_NAME CHAR(25),
  6     SALARY INT,
  7     -- JOINING_DATE DATETIME, datetime is not a data type in oracle
  8     JOINING_DATE DATE, -- date stores date and time both the component
  9     DEPARTMENT CHAR(25)
 10  );

Table created.

SQL>

Cheers!!

Popeye
  • 35,427
  • 4
  • 10
  • 31