Home > Software design >  How to rectify the ORA 00907 error missing right parenthesis?
How to rectify the ORA 00907 error missing right parenthesis?

Time:04-20

CREATE TABLE Attach_Files
(
    FileID INT IDENTITY(1,1) NOT NULL,
    Name NVARCHAR(50) NOT NULL,
    Files VARBINARY(MAX) NOT NULL
);

CodePudding user response:

Your code works in Microsoft SQL Server db<>fiddle

It does not work in Oracle as it is a different RDBMS with different syntax and you need to fix the syntax errors on most lines:

  • Identity columns need to be GENERATED [ALWAYS|BY DEFAULT] AS IDENTITY [(other options)]
  • NVARCHAR should be NVARCHAR2
  • VARBINARY(MAX) should be BLOB

You want:

CREATE TABLE Attach_Files
(
    FileID INTEGER
           GENERATED ALWAYS AS IDENTITY
           NOT NULL,
    Name   NVARCHAR2(50)
           NOT NULL,
    Files  BLOB NOT NULL
);

db<>fiddle here

CodePudding user response:

That IDENTITY(1,1) looks more like SQL Server syntax. For Oracle, use .. IDENTITY START WITH a INCREMENT BY n

Of course, can change a and n to the appropriate values for your case (a=1 and n=1).

CodePudding user response:

Try this statement:

    CREATE TABLE Attach_Files
(
    FileID INTEGER GENERATED ALWAYS AS IDENTITY
    (START WITH 1
    INCREMENT BY 1
    MAXVALUE 1000000
    CACHE 1
    CYCLE) NOT NULL,
    Name NVARCHAR(50) NOT NULL,
    Files VARBINARY(MAX) NOT NULL
);

Thank you.

  • Related