CREATE TABLE

Description

Creates a new table in the current database. You define a list of columns, which each hold data of a distinct type. The owner of the table is the issuer of the CREATE TABLE command.

For more information, please refer to CREATE TABLE documentation.

Grammar Syntax

CREATE [ { GLOBAL | LOCAL } TEMPORARY ] TABLE
   [ IF NOT EXISTS ] [ <owner>. ]<table-name>
   … ( <column-definition> [ <column-constraint> ] … 
   [ , <column-definition> [ <column-constraint> ] …]
   [ , <table-constraint> ] … ) 
   |{ ENABLE | DISABLE } RLV STORE
  
   …[ IN <dbspace-name> ]
   …[ ON COMMIT { DELETE | PRESERVE } ROWS ]
   [ AT <location-string> ]
   [PARTITION BY 
     <range-partitioning-scheme>
     | <hash-partitioning-scheme> 
     | <composite-partitioning-scheme> ]

<column-definition> ::=
   <column-name> <data-type> 
    [ [ NOT ] NULL ] 
    [ DEFAULT <default-value> | IDENTITY ] 
    [ PARTITION | SUBPARTITION ( <partition-name> IN  <dbspace-name> [ , ... ] ) ]

<default-value> ::=
   <special-value>
   | <string>
   | <global variable>
   | [ - ] <number>
   | ( <constant-expression> )
   | <built-in-function>( <constant-expression> )
   | AUTOINCREMENT
   | CURRENT DATABASE
   | CURRENT REMOTE USER
   | NULL
   | TIMESTAMP
   | LAST USER

<special-value> ::=
   CURRENT 
   { DATE | TIME | TIMESTAMP | USER | PUBLISHER }
   | USER

<column-constraint> ::=
   IQ UNIQUE ( <integer> )
   | { [ CONSTRAINT <constraint-name> ] 
     { UNIQUE  
        | PRIMARY KEY  
        | REFERENCES <table-name> [ ( <column-name> ) ] [ ON { UPDATE | DELETE } RESTRICT ] }
      [ IN <dbspace-name> ]
      | CHECK ( <condition> )
   }

<table-constraint> ::=
    [ CONSTRAINT <constraint-name> ] 
   {  { UNIQUE | PRIMARY KEY } ( <column-name> [ , … ] )  
     [ IN <dbspace-name> ]
     | <foreign-key-constraint>
     | CHECK ( <condition> )
   }

<foreign-key-constraint> ::=
   FOREIGN KEY [ <role-name> ] [ ( <column-name> [ , <column-name> ] … ) ] 
   …REFERENCES <table-name> [ ( <column-name> [ , <column-name> ] … ) ]
   …[ <actions> ] [ IN <dbspace-name> ]

<actions> ::=
   [ ON { UPDATE | DELETE } RESTRICT ]

<location-string> ::=
   { <remote-server-name>. [ <db-name> ].[ <owner> ].<object-name>
      | <remote-server-name>; [ <db-name> ]; [ <owner> ];<object-name> }

<range-partitioning-scheme> ::=
   RANGE ( <partition-key> ) ( <range-partition-decl> [,<range-partition-decl> … ] )

<partition-key> ::= <column-name>

<range-partition-declaration> ::=
    <range-partition-name> VALUES <= ( {<constant> |  MAX } ) [ IN <dbspace-name> ]

<hash-partitioning-scheme> ::=
   HASH ( <partition-key> [ , <partition-key>, … ] )

<composite-partitioning-scheme> ::=
   <hash-partitioning-scheme> SUBPARTITION BY <range-partitioning-scheme>

Last updated