Search code examples
oracle-databaseoracle11gora-00907

ORA-00907: missing right parenthesis when creating a table in Oracle 11G


In Oracle 11G, am recieving the error ORA-00907: missing right parenthesis when creating the table shown below

create table structured_1000( 
year varchar2(4) NOT NULL,
    CP varchar2(50),
      ONSG varchar2(50),
      ONSLA varchar2(9),
      road varchar2(100) NOT NULL,
      cat varchar2(20)
  Refs varchar2(20),
  Refn varchar2(20),
  ajunction varchar2(20),
  bjunction varchar2 (20),
  lennet char(2)`
   );

Ive listed the entire table as sometimes the error line changes - has shown both line 6 & 9. From what I can see all of the parenthesis are visible. This issue occurs in both the shell and APEX.


Solution

  • There are two issues in your create table statement:

    1. cat varchar2(20)

    You have a missing comma.

    1. lennet char(2)`

    An invalid backtick in the end.

    Fixing the two issue would successfully create the table:

    SQL> CREATE TABLE structured_1000
      2    (
      3      YEAR      VARCHAR2(4) NOT NULL,
      4      CP        VARCHAR2(50),
      5      ONSG      VARCHAR2(50),
      6      ONSLA     VARCHAR2(9),
      7      road      VARCHAR2(100) NOT NULL,
      8      cat       VARCHAR2(20),
      9      Refs      VARCHAR2(20),
     10      Refn      VARCHAR2(20),
     11      ajunction VARCHAR2(20),
     12      bjunction VARCHAR2 (20),
     13      lennet    CHAR(2)
     14    );
    
    Table created.
    
    SQL>