0
votes

I tried creating a table on oracle apex but when I run it, it shows the following error: ORA-00922: missing or invalid option. Here's my code:

CREATE TABLE  "PROD_INDEX" 
   (    
       "PNO" NUMBER (4,0) NOT NULL ENABLE,
    "CATEGORY" VARCHAR(15) , 
    "PRODUCT" VARCHAR2(10), 
    "COUNTRY" VARCHAR2(9), 
    "BRAND" VARCHAR(10)), 
    "DATE" DATE, 
    "YEAR" NUMBER(4,0), 
    "COST" NUMBER(7,2), 
    "SALES" NUMBER(10,2), 
     PRIMARY KEY ("PNO") ENABLE
   )
/

So what could be the problem?

3
Your code has a typo: "BRAND" VARCHAR(10)) . Remove the extra ( and your statement runs. Check out the Live SQL demo .APC

3 Answers

1
votes

Run the below statement.

CREATE TABLE "PROD_INDEX" 
(    
    "PNO" NUMBER (4,0) NOT NULL ENABLE,
    "CATEGORY" VARCHAR(15) , 
    "PRODUCT" VARCHAR2(10), 
    "COUNTRY" VARCHAR2(9), 
    "BRAND" VARCHAR(10), 
    "DATE" DATE, 
    "YEAR" NUMBER(4,0), 
    "COST" NUMBER(7,2), 
    "SALES" NUMBER(10,2), 
    PRIMARY KEY ("PNO") ENABLE
)
0
votes
CREATE TABLE  "PROD_INDEX" 
   (    
       "PNO" NUMBER (4,0),
    "CATEGORY" VARCHAR(15) , 
    "PRODUCT" VARCHAR2(10), 
    "COUNTRY" VARCHAR2(9), 
    "BRAND" VARCHAR(10)), 
    "DATE" DATE, 
    "YEAR" NUMBER(4,0), 
    "COST" NUMBER(7,2), 
    "SALES" NUMBER(10,2), 
     PRIMARY KEY ("PNO") ENABLE
   )

removed not null enable, and it works.

0
votes

Try this.

CREATE TABLE  "PROD_INDEX" 
   (    
    "PNO" NUMBER (4,0) PRIMARY KEY,
    "CATEGORY" VARCHAR(15) , 
    "PRODUCT" VARCHAR2(10), 
    "COUNTRY" VARCHAR2(9), 
    "BRAND" VARCHAR(10), 
    "DATE" DATE, 
    "YEAR" NUMBER(4,0), 
    "COST" NUMBER(7,2), 
    "SALES" NUMBER(10,2)
   )

Also, it is considered bad practice to name your columns after Oracle reserved words (e.g. date)