ORA-00907: missing right parenthesis .. when i don't have any missing parenthesis or spelling mistakes [closed] - sql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
When I run this SQL it gives me this error and I can't figure it out
CREATE TABLE PAYMENT (
Payment_ID int(16) not null,
Amount_paid varchar2(30) not null,
Payment_ReceivedBy varchar(30) not null,
Payment_ReceivedFrom varchar(30) not null,
Payment_Date datetime not null,
Card_Number varchar2(20) not null,
Card_Holder_Name varchar2(30) not null,
Is_CreditCard number(20) ,
Is_DebitCard number(20),
Online_Payment varchar(10),
CashOnDelivery varchar(10),
CONSTRAINT PaymentID_PK PRIMARY KEY (Payment_ID)
);
error:
ORA-00907: missing right parenthesis

The error message isn't great, and the issue in fact isn't really about parenthesis - it's about datatypes. Oracle doesn't have int and datetime types. Instead, you could use number(16) and date:
CREATE TABLE PAYMENT (
Payment_ID number(16) not null, -- Here
Amount_paid varchar2(30) not null,
Payment_ReceivedBy varchar(30) not null,
Payment_ReceivedFrom varchar(30) not null,
Payment_Date date not null, -- And here
Card_Number varchar2(20) not null,
Card_Holder_Name varchar2(30) not null,
Is_CreditCard number(20) ,
Is_DebitCard number(20),
Online_Payment varchar(10),
CashOnDelivery varchar(10),
CONSTRAINT PaymentID_PK PRIMARY KEY (Payment_ID)
);

Related

Error in my code: Syntax error: Expected ")" or "," but got "(" [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
$ CREATE TABLE `2021.dates_times` (
ride_id STRING NOT NULL,
start_hour TIME NOT NULL,
start_day INT NOT NULL,
start_month INT NOT NULL,
end_hour TIME NOT NULL,
end_day INT NOT NULL,
end_month INT NOT NULL
PRIMARY KEY (ride_id)
)$
You have left a comma before primary key.Your code should be
CREATE TABLE 2021.dates_times ( ride_id STRING NOT NULL, start_hour TIME NOT NULL, start_day INT NOT NULL, start_month INT NOT NULL, end_hour TIME NOT NULL, end_day INT NOT NULL, end_month INT NOT NULL, PRIMARY KEY (ride_id) )

Getting an error that I'm missing a right paren when I am not [duplicate]

This question already has answers here:
Missing right Paranthesis on Create Table command SQL
(2 answers)
Closed 3 years ago.
I'm getting an error when creating two tables that I'm missing a right paren on the second table although I am not.
I've tried different oracle variations of this code and I'm still getting the error.
(ORACLE LIVE SQL)
CREATE TABLE PET_OWNER
(OwnerID Integer Primary Key,
OwnerLastName Char(25) Not Null,
OwnerFirstName Char(25) Not Null,
OwnerPhone Char(25) Null,
OwnerEmail Char(50) Not Null);
CREATE TABLE PET_DATA
(PetID Integer Not Null,
PetName Char(50) Not Null,
PetType Char(25) Not Null,
PetBreed Char(50) Not Null,
PetDOB Varchar(50) Not Null,
Primary Key (PetID)
Constraint FK_PetOwner Foreign Key (OwnerID)
References Owner(OwnerID));
I expect the tables to be created but only the first table is being created successfully. The second table has a foreign key.
It looks like you are missing a comma after the primary-key definition on the second table.
The Oracle parser often complains about missing closing parentheses when the real issue is some other syntax error.
I would recommend:
CREATE TABLE PET_OWNER (
OwnerID Integer Primary Key,
OwnerLastName varchar2(25) Not Null,
OwnerFirstName varchar2(25) Not Null,
OwnerPhone varchar2(25) Null,
OwnerEmail varchar2(50) Not Null
);
CREATE TABLE PET_DATA (
PetID Integer Not Null,
OwnerID Integer,
PetName varchar2(50) Not Null,
PetType varchar2(25) Not Null,
PetBreed varchar2(50) Not Null,
PetDOB varchar2(50) Not Null,
Primary Key (PetID),
Constraint FK_PetOwner Foreign Key (OwnerID) References Pet_Owner(OwnerID)
);
This fixes small problems (missing OwnerId column in the second table, wrong table name). It also uses varchar2() for variable length strings rather than char() -- which are padded with spaces to the specified length.

ORA-00907: Missing right parenthesis [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have this code (for example)
CREATE TABLE s(
id int,
y int NOT NULL UNQIUE,
x int NOT NULL,
z varchar(50) NOT NULL,
k varchar(50),
l varchar(50) NOT NULL,
m int NOT NULL,
v int NOT NULL,
c int NOT NULL,
r varchar(400),
CONSTRAINT s_pk PRIMARY KEY (id));
But i get ORA-00907: Missing right parenthesis. What I made wrong?
CREATE TABLE s(
id int,
y int NOT NULL UNIQUE,
x int NOT NULL,
z varchar(50) NOT NULL,
k varchar(50),
l varchar(50) NOT NULL,
m int NOT NULL,
v int NOT NULL,
c int NOT NULL,
r varchar(400),
CONSTRAINT s_pk PRIMARY KEY (id));

ORA-00902: invalid datatype trying to define a column with a unique constraint [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I created the following table definition in netbeans ide 8.
CREATE TABLE DOCTOR_INFO(
DOCTOR_ID NUMBER(38) NOT NULL CONSTRAINT DOCTORINFO_ID_UQ UNIQUE,
D_F_NAME VARCHAR(50) NOT NULL,
D_M_NAME VARCHAR(50) NOT NULL,
D_S_NAME VARCHAR(50) NOT NULL,
DOCTOR_NAME VARCHAR(50),
D_TITLE VARCHAR(10) NOT NULL,
D_ACTIVE_STATUS BOOLEAN NOT NULL,
SUFFIX VARCHAR(10) NOT NULL,
PASSWORD VARCHAR(50) NOT NULL,
SPECIALITY VARCHAR(35) NOT NULL,
QUALIFICATION_YEAR NUMBER(4) NOT NULL,
UNIVERSITY_NAME VARCHAR(35) NOT NULL,
HOSPITAL_NAME VARCHAR(35) NOT NULL,
D_ADDR1 VARCHAR(50),
D_ADDR2 VARCHAR(50),
USER_EMAIL_ADDRESS VARCHAR(255) NOT NULL,
D_CITY VARCHAR(50) NOT NULL,
D_STATE VARCHAR(50),
D_ZIPCODE NUMBER(6) NOT NULL,
D_HOMEPHONE NUMBER(15) NOT NULL,
D_WORKPHONE NUMBER(15) NOT NULL,
D_MOBILE NUMBER(15) NOT NULL,
START_DAYTIME TIMESTAMP,
END_DAYTIME TIMESTAMP,
START_NIGHTTIME TIMESTAMP,
END_NIGHTTIME TIMESTAMP,
D_TOKENLIMIT NUMBER(4),
D_DOB DATE NOT NULL
);
When I try to run it in Oracle 10g, I get this error:
Error code 902, SQL state 42000: ORA-00902: invalid datatype
Line 1, column 1
What is wrong with the table definition?
Your definition for column DOCTOR_ID does not conform to Oracle SQL syntax. You cannot append a named constraint to a column declaration as you attempt to do. You may do this ...
DOCTOR_ID NUMBER(38) NOT NULL,
CONSTRAINT DOCTORINFO_ID_UQ UNIQUE (DOCTOR_ID),
... to achieve the effect you seem to want. If you don't care about the specific constraint name, however, then you can also do this:
DOCTOR_ID NUMBER(38) NOT NULL UNIQUE,

SQL Create table missing parenthesis [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am running these two commands to create new tables, but the second create table command keeps giving me error.
CREATE TABLE TEAMSTADIUM(
stadium_name varchar2(40) not null,
stadium_max_capcity number(10) not null,
stadium_field_serface varchar2(40) not null,
stadium_year_built number(4) not null,
stadium_location varchar2(40) not null,
Primary KEY(stadium_name)
)
CREATE TABLE TEAMINFO(
team_name varchar2(40) not null,
team_owner varchar2(40) not null,
team_coach varchar2(40) not null,
team_created Date() not null,
PRIMARY KEY(team_name)
foreign key(stadium_name) references TEAMSTADIUM(stadium_name)
)
Your TEAMINFO table references TEAMSTADIUM.stadium_name, but has no such column of its own. Add it, and ensure it has exactly the same data type as the parent table:
CREATE TABLE TEAMINFO(
team_name varchar2(40) not null,
team_owner varchar2(40) not null,
team_coach varchar2(40) not null,
team_created Date not null,
-- Remove () ^^
-- This column must exist in both tables
stadium_name varchar2(40) not null,
PRIMARY KEY(team_name),
-- missing comma ^^
foreign key(stadium_name) references TEAMSTADIUM(stadium_name)
)
After applying the three modifications above, it will execute correctly: http://sqlfiddle.com/#!4/883a4
Try using Date not null; and put ; after each ) of end table
CREATE TABLE TEAMINFO(
stadium_name varchar2(40) not null,
team_name varchar2(40) not null,
team_owner varchar2(40) not null,
team_coach varchar2(40) not null,
team_created Date not null,
PRIMARY KEY(team_name),
foreign key(stadium_name) references TEAMSTADIUM(stadium_name)
);