General syntax
This topic describes the general syntax of SQL statements, including constants, character sets, data types, SQL attributes, and storage attributes.
Constants
-
INT_VALUE: matches an integer constant, such as123. -
DECIMAL_VALUE: matches a fixed-point constant, such as123.456. -
STR_VALUE: matches a string constant, such asabc. -
NULL: matches theNULLconstant. -
STORAGE_SIZE: matches a storage length constant. The default unit for an integer constant is bytes. For a string constant, you can specify the unit as M or G. For example,1024or'500M'.
const_value:
INT_VALUE
| DECIMAL_VALUE
| STR_VALUE
| NULL
| STORAGE_SIZE
STORAGE_SIZE:
INT_VALUE
| 'INT_VALUE[M|G]'
Character sets
charset:
default_charset
| column_charset
default_charset:
[DEFAULT] {CHARSET | CHARACTER SET} [=] {UTF8 | UTF8MB4 | BINARY}
column_charset:
{CHARSET | CHARACTER SET} {UTF8 | UTF8MB4 | BINARY}
Collations
collate:
default_collate
| column_collate
default_collate:
[DEFAULT] COLLATE [=] {UTF8MB4_GENERAL_CI | UTF8MB4_BIN | BINARY}
column_collate:
COLLATE {UTF8MB4_GENERAL_CI | UTF8MB4_BIN | BINARY}
Data types
data_type:
TINYINT[(precision)] [UNSIGNED] [ZEROFILL]
| SMALLINT[(precision)] [UNSIGNED] [ZEROFILL]
| MEDIUMINT[(precision)] [UNSIGNED] [ZEROFILL]
| INT[(precision)] [UNSIGNED] [ZEROFILL]
| INTEGER[(precision)] [UNSIGNED] [ZEROFILL]
| BIGINT[(precision)] [UNSIGNED] [ZEROFILL]
| FLOAT[(precision, scale)] [UNSIGNED] [ZEROFILL]
| DOUBLE[(precision, scale)] [UNSIGNED] [ZEROFILL]
| DECIMAL[(precision [, scale])] [UNSIGNED] [ZEROFILL]
| NUMERIC[(precision [, scale])] [UNSIGNED] [ZEROFILL]
| DATETIME[(scale)]
| TIMESTAMP[(scale)]
| DATE
| TIME[(scale)]
| YEAR
| VARCHAR(length) column_charset column_collate
| VARBINARY(length)
| CHAR[(length)] column_charset column_collate
| BINARY[(length)]
| TINYTEXT column_charset column_collate
| TINYLOB
| TEXT[(length)] column_charset column_collate
| BLOB[(length)]
| MEDIUMTEXT column_charset column_collate
| MEDIUMBLOB
| LONGTEXT column_charset column_collate
| LONGBLOB
precision | scale | length:
INT_VALUE
SQL attributes
-
Object name
database_name | table_name | table_alias_name | column_name| column_alias_name | partition_name | subpartition_name:
STR_VALUE
index_name | view_name | object_name | constraint_name:
STR_VALUE
outline_name | user_name:
STR_VALUE
table_factor:
[[database_name].] table_name
column_factor:
[table_factor.] column_name -
Expression
expression:
const_value
| column_factor
| operator_expression
| function_expression -
Comment
comment:
COMMENT 'comment_text'
comment_text:
STR_VALUE
Storage attributes
-
BLOCK_SIZE: specifies the length of microblocks for object storage.block_size:
BLOCK_SIZE [=] INT_VALUE -
COMPRESSION: specifies the compression algorithm for object storage.compression:
COMPRESSION [=] {NONE | LZ4_1.0 | LZ0_1.0 | SNAPPY_1.0} -
PCTFREE: specifies the percentage of macroblocks reserved for object storage.pctfree:
PCTFREE [=] INT_VALUE -
TABLET_SIZE: specifies the minimum size of a tablet for a single task during parallel compaction.tablet_size:
TABLET_SIZE [=] INT_VALUE