'"ORA-00922: missing or invalid option" when creating tables

I entered the following SQL commands in Oracle but it complained "ORA-00922: missing or invalid option"

CREATE TABLE Student (
    StuID     NUMBER(15),
    StuName   VARCHAR2(50),
    Phone     VARCHAR2(20),
    PRIMARY KEY (StuID))

CREATE TABLE Program (
    ProCode       VARCHAR2(12),
    ProTitle      VARCHAR2(50),
    PRIMARY KEY (ProCode))

WHY???



Solution 1:[1]

If you are using the dreaded HTML GUI (inside the browser) of OracleXE then that does not support running more than one statement.

Use SQL Developer, SQL*Plus or any other GUI tool instead.

Solution 2:[2]

CREATE TABLE Student (
    StuID     NUMBER(15),
    StuName   VARCHAR2(50),
    Phone     VARCHAR2(20),
    CONSTRAINT PK_STUID PRIMARY KEY (StuID))

Found the answer here.

Edit:

Also, try using / as a statement separator, instead of a ;

Solution 3:[3]

Try no to define the size of StuID. also add constraint key work and just to make sure use DROP before CREATE like this:

DROP TABLE Student;

CREATE TABLE Student (
    StuID     NUMBER,
    StuName   VARCHAR2(50),
    Phone     VARCHAR2(20),
    constraint pk_Student PRIMARY KEY (StuID));

DROP TABLE Program;

CREATE TABLE Program (
    ProCode       VARCHAR2(12),
    ProTitle      VARCHAR2(50),
    constraint pk_Program PRIMARY KEY (ProCode));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Machavity
Solution 3