~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/create_table.rst

merge lp:~linuxjedi/drizzle/trunk-remove-drizzleadmin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
CREATE TABLE
2
2
============
3
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: ::
 
4
A CREATE statement in SQL creates an object inside of Drizzle. One of
 
5
the most common CREATE commands is the CREATE TABLE command.
 
6
 
 
7
.. code-block:: mysql
 
8
 
 
9
    CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
 
10
      (create_definition, ...)
 
11
      [engine_options]
 
12
 
 
13
or:
 
14
 
 
15
.. code-block:: mysql
 
16
 
 
17
    CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
 
18
      [(create_definition, ...)]
 
19
      [engine_options]
 
20
      select_statement
 
21
 
 
22
or:
 
23
 
 
24
.. code-block:: mysql
 
25
 
 
26
    CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
 
27
      LIKE different_table_name
 
28
      [engine_options]
 
29
 
 
30
create_definition
 
31
-----------------
 
32
 
 
33
::
24
34
 
25
35
    column_name column_definition
26
36
    [CONSTRAINT [symbol] ] PRIMARY KEY [index_type]
33
43
    reference_definition
34
44
    CHECK (expr)
35
45
 
36
 
column_definition: ::
 
46
column_definition
 
47
-----------------
 
48
 
 
49
::
37
50
 
38
51
        data_type [NOT NULL | NULL] [DEFAULT default_value]
39
52
    [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY]
40
53
    [COMMENT 'string']
41
54
    [reference_definition]
42
55
 
43
 
data_type: ::
 
56
data_type
 
57
---------
44
58
 
45
59
        * INTEGER
46
60
        * BIGINT
55
69
        * TEXT [BINARY] [COLLATE collation_name]
56
70
        * ENUM(value1, value2, value3, ...) [COLLATE collation_name]
57
71
 
58
 
reference_option:
 
72
reference_option
 
73
----------------
 
74
 
59
75
  RESTRICT | CASCADE | SET NULL | NO ACTION
60
76
 
61
 
engine_options:
 
77
engine_options
 
78
---------------
 
79
 
62
80
    engine_option [[,] engine_option] ...
63
81
 
64
 
engine_option:
 
82
engine_option
 
83
-------------
 
84
 
65
85
  ENGINE = engine_name
66
86
  { engine_specific }