Search code examples
sqloracle-databasedatabase-administrationpartition

Oracle missing or invalid option


I am trying to create a partition table by range separated by tablespace but the oracle throws error

Error report - ORA-00922: missing or invalid option 00922. 00000 - "missing or invalid option"

The SQL statement:

create table sales (year number(4),
                product varchar2(10),
               amt number(10,2))
               PARTITION by range(year)
 partition p1 values less than (1992) tablespace u1,
 partition p2 values less than (1993) tablespace u2,
 partition p3 values less than (1994) tablespace u3,
 partition p4 values less than (1995) tablespace u4,
 partition p5 values less than (MAXVALUE) tablespace u5;

Created all tablespaces and user is sysdba


Solution

  • PARTITIONs should be enclosed into parenthesis:

    SQL> CREATE TABLE sales
      2  (
      3     year      NUMBER (4),
      4     product   VARCHAR2 (10),
      5     amt       NUMBER (10, 2)
      6  )
      7  PARTITION BY RANGE (year)
      8   (PARTITION p1 VALUES LESS THAN (1992)     TABLESPACE USER_DATA,
      9    PARTITION p2 VALUES LESS THAN (1993)     TABLESPACE USER_DATA,
     10    PARTITION p3 VALUES LESS THAN (1994)     TABLESPACE USER_DATA,
     11    PARTITION p4 VALUES LESS THAN (1995)     TABLESPACE USER_DATA,
     12    PARTITION p5 VALUES LESS THAN (MAXVALUE) TABLESPACE USER_DATA
     13   );
    
    Table created.
    
    SQL>
    

    (I don't have your tablespaces so I used the one I have, but that's irrelevant in this case).