~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/create_table.rst

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
CREATE TABLE
2
 
============
3
 
 
4
 
A CREATE statement in SQL creates an object inside of Drizzle. One of the most common CREATE command is the CREATE TABLE command.
5
 
 
6
 
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
7
 
    (create_definition, ...)
8
 
    [engine_options]
9
 
 
10
 
    or:
11
 
 
12
 
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
13
 
    [(create_definition, ...)]
14
 
    [engine_options]
15
 
    select_statement
16
 
 
17
 
    or:
18
 
 
19
 
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
20
 
    LIKE different_table_name
21
 
    [engine_options]
22
 
 
23
 
create_definition: ::
24
 
 
25
 
    column_name column_definition
26
 
    [CONSTRAINT [symbol] ] PRIMARY KEY [index_type]
27
 
    (index_column_name, ...)
28
 
    INDEX [index_name] (index_column_name, ...)
29
 
    (index_column_name, ...)
30
 
    [CONSTRAINT [symbol] ] UNIQUE [INDEX]
31
 
    (index_column_name, ...)
32
 
    [CONSTRAINT [symbol] ] FOREIGN KEY [index_name] (index_column_name, ...)
33
 
    reference_definition
34
 
    CHECK (expr)
35
 
 
36
 
column_definition: ::
37
 
 
38
 
        data_type [NOT NULL | NULL] [DEFAULT default_value]
39
 
    [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY]
40
 
    [COMMENT 'string']
41
 
    [reference_definition]
42
 
 
43
 
data_type: ::
44
 
 
45
 
        * INTEGER
46
 
        * BIGINT
47
 
        * DOUBLE[(length, decimals)]
48
 
        * DECIMAL[(length[,decimals])]
49
 
        * DATE
50
 
        * TIMESTAMP
51
 
        * DATETIME
52
 
        * VARCHAR(length) [COLLATE collation_name]
53
 
        * VARBINARY(length)
54
 
        * BLOB
55
 
        * TEXT [BINARY] [COLLATE collation_name]
56
 
        * ENUM(value1, value2, value3, ...) [COLLATE collation_name]
57
 
 
58
 
reference_option:
59
 
  RESTRICT | CASCADE | SET NULL | NO ACTION
60
 
 
61
 
engine_options:
62
 
    engine_option [[,] engine_option] ...
63
 
 
64
 
engine_option:
65
 
  ENGINE = engine_name
66
 
  { engine_specific }