create table 句法

來源:互聯網
上載者:User

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options] [select_statement]

create_definition:

col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]

[PRIMARY KEY] [reference_definition]

or PRIMARY KEY (index_col_name,...)

or KEY [index_name] (index_col_name,...)

or INDEX [index_name] (index_col_name,...)

or UNIQUE [INDEX] [index_name] (index_col_name,...)

or [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)

[reference_definition]

or CHECK (expr)

 

type:

TINYINT[(length)] [UNSIGNED] [ZEROFILL]

or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]

or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]

or INT[(length)] [UNSIGNED] [ZEROFILL]

or INTEGER[(length)] [UNSIGNED] [ZEROFILL]

or BIGINT[(length)] [UNSIGNED] [ZEROFILL]

or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]

or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]

or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]

or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]

or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]

or CHAR(length) [BINARY]

or VARCHAR(length) [BINARY]

 

or DATE

or TIME

or TIMESTAMP

or DATETIME

or TINYBLOB

or BLOB

or MEDIUMBLOB

or LONGBLOB

or TINYTEXT

or TEXT

or MEDIUMTEXT

or LONGTEXT

or ENUM(value1,value2,value3,...)

or SET(value1,value2,value3,...)

index_col_name:

col_name [(length)]

reference_definition :

REFERENCES tbl_name [(index_col_name,...)]

[MATCH FULL | MATCH PARTIAL]

[ON DELETE reference_option]

[ON UPDATE reference_option]

reference_option:

RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT

table_options:

TYPE = {ISAM | MYISAM | HEAP}

or AUTO_INCREMENT = #

or AVG_ROW_LENGTH = #

or CHECKSUM = {0 | 1}

or COMMENT = "string"

or MAX_ROWS = #

or MIN_ROWS = #

or PACK_KEYS = {0 | 1}

or PASSWORD = "string"

or DELAY_KEY_WRITE = {0 | 1}

or ROW_FORMAT= { default | dynamic | static | compressed }

select_statement:

[IGNORE | REPLACE] SELECT ... (Some legal select statement)


例如:


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.