create table course(
cno number(6) primary key,
cname char(20) unique
using index tablespace indx storge(initial 64k next 64k)
)
运行时报错:
create table course(
                   *
ERROR 位于第 1 行:
ORA-00922:缺少或无效选项

解决方案 »

  1.   

    你的脚本写法有问题吧,给你看个脚本
    CREATE TABLE POST --建表
    (
      SEQ_NO     CHAR(6 BYTE),
      AREA_GB    VARCHAR2(2 BYTE),
      CITY_NAME  VARCHAR2(30 BYTE),
      CITY       CHAR(4 BYTE),
      GU_NAME    VARCHAR2(30 BYTE),
      COUNTRY    CHAR(6 BYTE),
      DONG_NAME  VARCHAR2(30 BYTE),
      POST_NO    VARCHAR2(6 BYTE),
      POST_SEQ   CHAR(3 BYTE)                       DEFAULT '001'
    )
    TABLESPACE ORDER_DAT --表空间
    PCTUSED    0
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
               )
    LOGGING 
    NOCOMPRESS 
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE UNIQUE INDEX POST_PK ON POST --建立UNIQUE
    (POST_SEQ, POST_NO)
    LOGGING
    TABLESPACE ORDER_DAT
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
               )
    NOPARALLEL;
    ALTER TABLE POST ADD ( --建PK
      CONSTRAINT POST_PK
     PRIMARY KEY
     (POST_SEQ, POST_NO)
        USING INDEX 
        TABLESPACE ORDER_DAT
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    PCTINCREASE      0
                   ));
      

  2.   

    SQL> help create table CREATE TABLE
     ------------ Use this command to create a table, the basic structure to hold user
     data, specifying the following information:   *  column definitions
       *  table organization definition
       *  column definitions using objects
       *  integrity constraints
       *  the table's tablespace
       *  storage characteristics
       *  an optional cluster
       *  data from an arbitrary query
       *  degree of parallelism used to create the table and the default
          degree of parallelism for queries on the table
       *  partitioning definitions Use CREATE TABLE to create an object table or a table that uses an
     object type for a column definition. An object table is a table
     explicitly defined to hold object instances of a particular type. You can also create an object type and then use it in a column when
     creating a relational table. Relational table definition
       CREATE TABLE [schema.]table
         [ ( { column datatype [DEFAULT expr] [WITH ROWID]
               [SCOPE IS [schema.]scope_table_name]
               [column_constraint] ...
             | table_constraint | REF (ref_column_name) WITH ROWID
             | SCOPE FOR (ref_column_name) IS [schema.]scope_table_name }
          [, { column datatype [DEFAULT expr] [WITH ROWID]
               [SCOPE IS [schema.]scope_table_name]
               [column_constraint] ...
             | table_constraint | REF (ref_column_name) WITH ROWID
             | SCOPE FOR (ref_column_name) IS
               [schema.]scope_table_name} ] ...) ]
         [ { [ ORGANIZATION {HEAP | INDEX}
               | PCTTHRESHOLD [INCLUDING column_name]
               [ OVERFLOW [physical_attributes_clause |
                 TABLESPACE tablespace] ...]
             | physical_attributes_clause
             | TABLESPACE tablespace
               | LOB (lob_item [, lob_item ...] ) STORE AS
                 [lob_segname]
               [ ( TABLESPACE tablespace
                 | STORAGE storage_clause
                 | CHUNK integer
                 | PCTVERSION integer
                 | CACHE
                 | NOCACHE LOGGING | NOCACHE NOLOGGING
                 | INDEX [lob_index_name]
                 [ ( TABLESPACE tablespace
                   |  STORAGE storage_clause
                   |  INITRANS integer
                   |  MAXTRANS integer ) ...] ) ]
               | NESTED TABLE nested_item STORE AS storage_table
               | {LOGGING | NOLOGGING} ] ...
             | CLUSTER cluster (column [, column] ...) } ]
           [ PARALLEL parallel_clause]
           [ PARTITION BY RANGE (column_list)
             ( PARTITION [partition_name] VALUES LESS THAN (value_list)
               [ physical_attributes_clause
               | TABLESPACE tablespace
               | {LOGGING | NOLOGGING} ] ) ...]
           [ ENABLE enable_clause | DISABLE disable_clause] ...
             [AS subquery]
             [CACHE | NOCACHE] physical_attributes_clause
       [ PCTFREE integer
       | PCTUSED integer
       | INITRANS integer
       | MAXTRANS integer
       | STORAGE storage_clause ] Object table definition
       CREATE TABLE [schema.]table OF [schema.]object_type
         [ ( [ column | attribute [DEFAULT expr] [WITH ROWID]
             [ SCOPE IS [schema.]scope_table_name]
             [column_constraint] ...]
           | table_constraint | REF (ref_column_name) WITH ROWID
           | SCOPE FOR (ref_column_name) IS [schema.]scope_table_name
           [, { column | attribute [DEFAULT expr] [WITH ROWID]
              [ SCOPE IS [schema.]scope_table_name]
              [column_constraint] ...
              | table_constraint | REF (ref_column_name) WITH ROWID
              | SCOPE FOR (ref_column_name) IS
                [schema.]scope_table_name} ] ...) ]
         [ OIDINDEX [index] [( physical_attributes_clause |
                TABLESPACE tablespace) ...]
           [ { [ physical_attributes_clause
               | TABLESPACE tablespace
               | LOB (lob_item [, lob_item ...]) STORE AS
                 [ lob_segname]
                 [ ( TABLESPACE tablespace
                   | STORAGE storage_clause
                   | CHUNK integer
                   | PCTVERSION integer
                   | CACHE
                   | NOCACHE LOGGING | NOCACHE NOLOGGING
                   | INDEX [lob_index_name]
                     [ ( TABLESPACE tablespace
                       |  STORAGE storage_clause
                       |  INITRANS integer
                       |  MAXTRANS integer ) ] ) ]
               | NESTED TABLE nested_item STORE AS storage_table
               | {LOGGING | NOLOGGING} ] ...
             | CLUSTER cluster (column [, column] ...) } ]
         [ PARALLEL parallel_clause]
         [ ENABLE enable_clause | DISABLE disable_clause] ...
         [ AS subquery]
         [ CACHE | NOCACHE] For detailed information on this command, see the Oracle8 Server SQL
     Reference.
     CREATE TABLESPACE
     ----------------- Use this command to create a tablespace. A tablespace is an
     allocation of space in the database that can contain schema objects. CREATE TABLESPACE tablespace
     DATAFILE filespec
       [ AUTOEXTEND
         { OFF | ON
           [ NEXT integer [K | M] ]
           [ MAXSIZE
             { UNLIMITED | integer [K | M] } ] } ]
       [ LOGGING | NOLOGGING]
       [, filespec
         [ AUTOEXTEND
           { OFF | ON
             [ NEXT integer [K | M] ]
             [ MAXSIZE
               { UNLIMITED | integer [K | M] } ] } ] ]
       [LOGGING | NOLOGGING] ...
       [ MINIMUM EXTENT integer [K | M] ]
       [ DEFAULT STORAGE storage_clause
         | {ONLINE | OFFLINE}
         | {PERMANENT | TEMPORARY} ] ... For detailed information on this command, see the Oracle8 Server SQL
     Reference.
    SQL>
      

  3.   

    主键创建的位置问题吧?你那不是ORACLE的建表语句吧?CREATE TABLE HYX0X.BOOKS
    (
        CATALOG_NUMBER                 NUMBER(4,0) NOT NULL,
        TITLE                          VARCHAR2(40),
        AUTHOR1                        VARCHAR2(40),
        AUTHOR2                        VARCHAR2(40),
        AUTHOR3                        VARCHAR2(40),
        AUTHOR4                        VARCHAR2(40),
        CONSTRAINT SYS_C002181 PRIMARY KEY (CATALOG_NUMBER) USING INDEX   --主键创建的位置
            PCTFREE 10
            INITRANS 2
            MAXTRANS 255
            TABLESPACE USERS
            STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
            LOGGING
    )
      

  4.   

    1.storage写错了;
    2.tablespace 应该写在后面;
    SQL> create table course(
      2  cno number(6) primary key using index storage(initial 64k next 64k) tablespace indx,
      3  cname char(20) unique
      4  )
      5  /Table created