CREATE TABLE Syntax
 CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
     { LIKE old_tbl_name | (LIKE old_tbl_name) }
 
 # create_definition:
     col_name column_definition
   | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...)
       [index_option] ...
   | {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
       [index_option] ...
   | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]
       [index_name] [index_type] (index_col_name,...)
       [index_option] ...
   | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...)
       [index_option] ...
   | [CONSTRAINT [symbol]] FOREIGN KEY
       [index_name] (index_col_name,...) reference_definition
   | CHECK (expr)
 
 # column_definition:
     data_type [NOT NULL | NULL] [DEFAULT default_value]
       [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY]
       [COMMENT 'string']
       [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}]
       [reference_definition]
 
 # data_type:
     BIT[(length)]
   | TINYINT[(length)] [UNSIGNED] [ZEROFILL]
   | SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
   | MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
   | INT[(length)] [UNSIGNED] [ZEROFILL]
   | INTEGER[(length)] [UNSIGNED] [ZEROFILL]
   | BIGINT[(length)] [UNSIGNED] [ZEROFILL]
   | REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
   | DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
   | FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
   | DECIMAL[(length[,decimals])] [UNSIGNED] [ZEROFILL]
   | NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL]
   | DATE
   | TIME
   | TIMESTAMP
   | DATETIME
   | YEAR
   | CHAR[(length)]
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | VARCHAR(length)
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | BINARY[(length)]
   | VARBINARY(length)
   | TINYBLOB
   | BLOB
   | MEDIUMBLOB
   | LONGBLOB
   | TINYTEXT [BINARY]
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | TEXT [BINARY]
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | MEDIUMTEXT [BINARY]
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | LONGTEXT [BINARY]
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | ENUM(value1,value2,value3,...)
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | SET(value1,value2,value3,...)
       [CHARACTER SET charset_name] [COLLATE collation_name]
   | spatial_type
 
 # index_col_name:
     col_name [(length)] [ASC | DESC]
 
 # index_type:
     USING {BTREE | HASH | RTREE}
 
 # index_option:
     KEY_BLOCK_SIZE [=] value
   | index_type
   | WITH PARSER parser_name
 
 # reference_definition:
     REFERENCES tbl_name (index_col_name,...)
       [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
       [ON DELETE reference_option]
       [ON UPDATE reference_option]
 
 # reference_option:
     RESTRICT | CASCADE | SET NULL | NO ACTION
 
 # table_options:
     table_option [[,] table_option] ...
 
 # table_option:
     ENGINE [=] engine_name
   | AUTO_INCREMENT [=] value
   | AVG_ROW_LENGTH [=] value
   | [DEFAULT] CHARACTER SET [=] charset_name
   | CHECKSUM [=] {0 | 1}
   | [DEFAULT] COLLATE [=] collation_name
   | COMMENT [=] 'string'
   | CONNECTION [=] 'connect_string'
   | DATA DIRECTORY [=] 'absolute path to directory'
   | DELAY_KEY_WRITE [=] {0 | 1}
   | INDEX DIRECTORY [=] 'absolute path to directory'
   | INSERT_METHOD [=] { NO | FIRST | LAST }
   | KEY_BLOCK_SIZE [=] value
   | MAX_ROWS [=] value
   | MIN_ROWS [=] value
   | PACK_KEYS [=] {0 | 1 | DEFAULT}
   | PASSWORD [=] 'string'
   | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
   | UNION [=] (tbl_name[,tbl_name]...)
 
 # partition_options:
     PARTITION BY
         { [LINEAR] HASH(expr)
         | [LINEAR] KEY(column_list)
         | RANGE{(expr) | COLUMNS(column_list)}
         | LIST{(expr) | COLUMNS(column_list)} }
     [PARTITIONS num]
     [SUBPARTITION BY
         { [LINEAR] HASH(expr)
         | [LINEAR] KEY(column_list) }
       [SUBPARTITIONS num]
     ]
     [(partition_definition [, partition_definition] ...)]
 
 # partition_definition:
     PARTITION partition_name
         [VALUES 
             {LESS THAN {(expr | value_list) | MAXVALUE} 
             | 
             IN (value_list | value_list)}]
         [[STORAGE] ENGINE [=] engine_name]
         [COMMENT [=] 'comment_text' ]
         [DATA DIRECTORY [=] 'data_dir']
         [INDEX DIRECTORY [=] 'index_dir']
         [MAX_ROWS [=] max_number_of_rows]
         [MIN_ROWS [=] min_number_of_rows]
         [(subpartition_definition [, subpartition_definition] ...)]
 
 # subpartition_definition:
     SUBPARTITION logical_name
         [[STORAGE] ENGINE [=] engine_name]
         [COMMENT [=] 'comment_text' ]
         [DATA DIRECTORY [=] 'data_dir']
         [INDEX DIRECTORY [=] 'index_dir']
         [MAX_ROWS [=] max_number_of_rows]
         [MIN_ROWS [=] min_number_of_rows]
 
 # select_statement:
     [IGNORE | REPLACE] [AS] SELECT ...   (Some legal select statement)
 

CREATE VIEW Syntax
 CREATE
     [OR REPLACE]
     [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
     [DEFINER = { user | CURRENT_USER }]
     [SQL SECURITY { DEFINER | INVOKER }]
     VIEW view_name [(column_list)]
     AS select_statement
     [WITH [CASCADED | LOCAL] CHECK OPTION]
 

CREATE PROCEDURE / FUNCTION Syntax
 CREATE
     [DEFINER = { user | CURRENT_USER }]
     PROCEDURE sp_name ([proc_parameter[,...]])
     [characteristic ...] routine_body
 
 CREATE
     [DEFINER = { user | CURRENT_USER }]
     FUNCTION sp_name ([func_parameter[,...]])
     RETURNS type
     [characteristic ...] routine_body
 
 # proc_parameter:
     [ IN | OUT | INOUT ] param_name type
 
 # func_parameter:
     param_name type
 
 # type:
     Any valid MySQL data type
 
 # characteristic:
     LANGUAGE SQL
   | [NOT] DETERMINISTIC
   | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
   | SQL SECURITY { DEFINER | INVOKER }
   | COMMENT 'string'
 
 # routine_body:
     Valid SQL procedure statement
 

CREATE INDEX Syntax
 CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name
     [index_type]
     ON tbl_name (index_col_name,...)
     [index_option] ...
 
 # index_col_name:
     col_name [(length)] [ASC | DESC]
 
 # index_type:
     USING {BTREE | HASH | RTREE}
 
 # index_option:
     KEY_BLOCK_SIZE [=] value
   | index_type
   | WITH PARSER parser_name
 

CREATE SCHEMA Syntax
 CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
     [create_specification] ...
 
 # create_specification:
     [DEFAULT] CHARACTER SET [=] charset_name
   | [DEFAULT] COLLATE [=] collation_name
 

ALTER TABLE Syntax
 ALTER [IGNORE] TABLE tbl_name
     alter_specification [, alter_specification] ...
 
 # alter_specification:
     table_options
   | ADD [COLUMN] col_name column_definition
         [FIRST | AFTER col_name ]
   | ADD [COLUMN] (col_name column_definition,...)
   | ADD {INDEX|KEY} [index_name]
         [index_type] (index_col_name,...) [index_option] ...
   | ADD [CONSTRAINT [symbol]] PRIMARY KEY
         [index_type] (index_col_name,...) [index_option] ...
   | ADD [CONSTRAINT [symbol]]
         UNIQUE [INDEX|KEY] [index_name]
         [index_type] (index_col_name,...) [index_option] ...
   | ADD FULLTEXT [INDEX|KEY] [index_name]
         (index_col_name,...) [index_option] ...
   | ADD SPATIAL [INDEX|KEY] [index_name]
         (index_col_name,...) [index_option] ...
   | ADD [CONSTRAINT [symbol]]
         FOREIGN KEY [index_name] (index_col_name,...)
         reference_definition
   | ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
   | CHANGE [COLUMN] old_col_name new_col_name column_definition
         [FIRST|AFTER col_name]
   | MODIFY [COLUMN] col_name column_definition
         [FIRST | AFTER col_name]
   | DROP [COLUMN] col_name
   | DROP PRIMARY KEY
   | DROP {INDEX|KEY} index_name
   | DROP FOREIGN KEY fk_symbol
   | DISABLE KEYS
   | ENABLE KEYS
   | RENAME [TO] new_tbl_name
   | ORDER BY col_name [, col_name] ...
   | CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]
   | [DEFAULT] CHARACTER SET [=] charset_name [COLLATE [=] collation_name]
   | DISCARD TABLESPACE
   | IMPORT TABLESPACE
   | partition_options
   | ADD PARTITION (partition_definition)
   | DROP PARTITION partition_names
   | TRUNCATE PARTITION {partition_names | ALL }
   | COALESCE PARTITION number
   | REORGANIZE PARTITION [partition_names INTO (partition_definitions)]
   | ANALYZE PARTITION  {partition_names | ALL }
   | CHECK PARTITION  {partition_names | ALL }
   | OPTIMIZE PARTITION  {partition_names | ALL }
   | REBUILD PARTITION  {partition_names | ALL }
   | REPAIR PARTITION  {partition_names | ALL }
   | REMOVE PARTITIONING
 
 # index_col_name:
     col_name [(length)] [ASC | DESC]
 
 # index_type:
     USING {BTREE | HASH | RTREE}
 
 # index_option:
     KEY_BLOCK_SIZE [=] value
   | index_type
   | WITH PARSER parser_name
 
 # table_options:
     table_option [[,] table_option] ...
 

ALTER VIEW Syntax
 ALTER
     [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
     [DEFINER = { user | CURRENT_USER }]
     [SQL SECURITY { DEFINER | INVOKER }]
     VIEW view_name [(column_list)]
     AS select_statement
     [WITH [CASCADED | LOCAL] CHECK OPTION]
 

ALTER PROCEDURE/FUNCTION Syntax
 ALTER PROCEDURE proc_name [characteristic ...]
 
 # or
 ALTER FUNCTION func_name [characteristic ...]
 
 # characteristic:
     { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
   | SQL SECURITY { DEFINER | INVOKER }
   | COMMENT 'string'
 

DROP TABLE Syntax
 DROP [TEMPORARY] TABLE [IF EXISTS]
     tbl_name [, tbl_name] ...
     [RESTRICT | CASCADE]
 

DROP VIEW Syntax
 DROP VIEW [IF EXISTS]
     view_name [, view_name] ...
     [RESTRICT | CASCADE]
 

