Confusing Error About Missing Left Parenthesis in SQL Statement

Confusing error about missing left parenthesis in SQL statement

VARCHAR2 is a type that needs a maximum size/length. Try something like...

varchar2(50)

Your missing left parenthesis is the parenthesis that surrounds the size.

CREATE TABLE people(
id INT NOT NULL PRIMARY KEY,
name VARCHAR2(50)
);

Oracle - Error missing left parenthesis when CREATE TABLE

You can't use the comma sign after the column definition. You can use them if there are multiple columns, but not when only one column. Look the following example -

Create Table A (
i int,
j int
);

and for one column -

Create Table A (
i int
);

ORA-009906: Missing left parenthesis error?

It should be like this:

CREATE TABLE new_table (driver_license  VARCHAR2(20),
SSN NUMBER(10,0),
first_name VARCHAR2(20),
last_name VARCHAR2(20) NOT NULL,
birth_date DATE,
hire_date DATE, -- The hire_date corresponds to when the employee is *first* hired.--
state CHAR(2 BYTE) DEFAULT 'UD',
CONSTRAINT ssn_pk PRIMARY KEY (SSN),
Constraint ssn_chk CHECK (hire_date > birth_date),
Constraint ssn_uq UNIQUE(driver_license)
);

If you want to create also index on (state), you should use separate DDL command:

Create index ssn_state_ix on new_table (state) ;

sql developer error ORA-00906: missing left parenthesis

I think the issue is a missing length on varchar2():

CREATE TABLE Representatives (
ID NUMBER(4) NOT NULL PRIMARY KEY,
State CHAR(2) NOT NULL,
District NUMBER NOT NULL CHECK(District>=1 AND District<=30),
Party VARCHAR2(30),
LastName VARCHAR2(20),
Firstname VARCHAR2(20),
StartOfTerm DATE,
EndOfTerm DATE,
SenRank VARCHAR2(255) CHECK (senRank IN ('junior', 'senior')),
-----------------^
Gender CHAR(1) CHECK (Gender IN ('M', 'F')),
Birthdate DATE,
FOREIGN KEY (State) REFERENCES States(State),
FOREIGN KEY (Party) REFERENCES Parties(Party)
);

Here is a db<>fiddle, without the foreign key declarations.



Related Topics



Leave a reply



Submit