~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/create_table.rst

  • Committer: Joseph Daly
  • Date: 2010-10-30 01:01:48 UTC
  • mfrom: (1891 staging)
  • mto: This revision was merged to the branch mainline in revision 1900.
  • Revision ID: skinny.moey@gmail.com-20101030010148-k39lnrftv4bkbux9
merge trunk

Show diffs side-by-side

added added

removed removed

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