~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/create_table.rst

  • Committer: Andrew Hutchings
  • Date: 2011-02-15 22:26:36 UTC
  • mto: (2172.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2173.
  • Revision ID: andrew@linuxjedi.co.uk-20110215222636-sekn9d21832u9wvs
Missed something on temporal docs, now fixed

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
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
 
::
 
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: ::
34
24
 
35
25
    column_name column_definition
36
26
    [CONSTRAINT [symbol] ] PRIMARY KEY [index_type]
43
33
    reference_definition
44
34
    CHECK (expr)
45
35
 
46
 
column_definition
47
 
-----------------
48
 
 
49
 
::
 
36
column_definition: ::
50
37
 
51
38
        data_type [NOT NULL | NULL] [DEFAULT default_value]
52
39
    [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY]
53
40
    [COMMENT 'string']
54
41
    [reference_definition]
55
42
 
56
 
data_type
57
 
---------
 
43
data_type: ::
58
44
 
59
45
        * INTEGER
60
46
        * BIGINT
69
55
        * TEXT [BINARY] [COLLATE collation_name]
70
56
        * ENUM(value1, value2, value3, ...) [COLLATE collation_name]
71
57
 
72
 
reference_option
73
 
----------------
74
 
 
 
58
reference_option:
75
59
  RESTRICT | CASCADE | SET NULL | NO ACTION
76
60
 
77
 
engine_options
78
 
---------------
79
 
 
 
61
engine_options:
80
62
    engine_option [[,] engine_option] ...
81
63
 
82
 
engine_option
83
 
-------------
84
 
 
 
64
engine_option:
85
65
  ENGINE = engine_name
86
66
  { engine_specific }