Question:
ORA-00922: missing or invalid option?
ST
2013-04-22 08:42:41 UTC
CREATE TABLE STUDENT(
STUDENTID integer,
STUDENTNAME varchar2(25),
Constraint S_STUDENTID primary key (STUDENTID)
)
INSERT INTO STUDENT(STUDENTID, STUDENTNAME)
VALUES(38214, 'Letersky')
INSERT INTO STUDENT(STUDENTID, STUDENTNAME)
VALUES(54907, 'Altvater')
INSERT INTO STUDENT(STUDENTID, STUDENTNAME)
VALUES(66324, 'Aiken')
INSERT INTO STUDENT(STUDENTID, STUDENTNAME)
VALUES(70542, 'Marra');

I am creating this table in SQL and it keeps giving me errors. The last error I have to fix is this:

INSERT INTO STUDENT(STUDENTID, STUDENTNAME)
*

ERROR at line 6:
ORA-00922: missing or invalid option

I tried adding semicolons and editing the INSERT INTO lines but that didn't work.
Three answers:
Ryan Young
2013-04-22 12:14:56 UTC
Serge is correct, you are missing four semicolons. This has nothing to do with the spacing, or lack thereof, between STUDENT and ( in the INSERT statement. You need a semicolon between statements. Plain and simple.
Almighty Wizard
2013-04-22 15:52:06 UTC
Make sure you have spaces between "STUDENT" and "(STUDENTID...)". The same thing for "VALUES".



It looks like SQL is assuming STUDENT and VALUES are functions since there is no space between the keyword and the '('.



Where is 'line 6' in your script? If anything, you may be having an issue because the create table statement never completes. You need to have semi-colons after each of your statements, including the create table statement.
Serge M
2013-04-22 17:26:44 UTC
This way:



CREATE TABLE STUDENT(

STUDENTID integer,

STUDENTNAME varchar2(25),

Constraint S_STUDENTID primary key (STUDENTID)

);

INSERT INTO STUDENT(STUDENTID, STUDENTNAME)

VALUES(38214, 'Letersky');

INSERT INTO STUDENT(STUDENTID, STUDENTNAME)

VALUES(54907, 'Altvater');

INSERT INTO STUDENT(STUDENTID, STUDENTNAME)

VALUES(66324, 'Aiken') ;

INSERT INTO STUDENT(STUDENTID, STUDENTNAME)

VALUES(70542, 'Marra');


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...