CREATE TABLE syntax

Source: Internet
Author: 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)


For example:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.