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
Delphi: Accessing JSON Objects Within a JSON Array
Apply Like Over All Columns Without Specifying All Column Names
Making Ssdt Just Generate a SQL Script (And Not Deploy a Database)
How to Update an Xml Attribute Value in an Xml Variable Using T-Sql
Performance Difference Between Primary Key and Unique Clustered Index in SQL Server
There Is Already an Object Named '##Temp' in The Database
Cannot Connect to SQL Server Express from Ssms
How to Get First and Last Day of Week in Oracle
Sql Server Database Change Workflow Best Practices
Postgresql: Table Name/Schema Confusion
Oracle SQL Developer 3.1.07 Extra Spaces Between Characters Using Listagg
How to Group by One Column and Retrieve a Row with The Minimum Value of Another Column in T/Sql
Sql Field with Multiple Id's of Other Table
Order of Execution in SQL Server Variable Assignment Using Select
Difference Between "||" Operator and Concat Function in Oracle
Insert Binary File into Mssql Db (Varbinary) with Python Pymssql