~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/create_table.rst

  • Committer: Andrew Hutchings
  • Date: 2011-02-23 14:17:23 UTC
  • mto: (2196.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2197.
  • Revision ID: andrew@linuxjedi.co.uk-20110223141723-spck4t85k8igzk4j
Markup fixes

Show diffs side-by-side

added added

removed removed

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