关键字

本章介绍 MatrixOne 的关键字,在 MatrixOne 中对保留关键字和非保留关键字进行了分类,你在使用 SQL 语句时,可以查阅保留关键字和非保留关键字。

关键字是 SQL 语句中具有特殊含义的单词,例如 SELECTUPDATEDELETE 等等。

  • 保留关键字:关键字中需要经过特殊处理才能作为标识符的字,被称为保留关键字。

将保留关键字作为标识符使用时,必须使用反引号包裹,否则将产生报错:

  1. \\未将保留关键字 select 使用反引号包裹,产生报错
  2. mysql> CREATE TABLE select (a INT);
  3. ERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 19 near " select (a INT)";
  4. \\正确将保留关键字 select 使用反引号包裹
  5. mysql> CREATE TABLE `select` (a INT);
  6. Query OK, 0 rows affected (0.02 sec)
  • 非保留关键字:关键字中可以直接作为标识符,被称为非保留关键字。

将非保留关键字作为标识符使用时,可以直接使用,无需使用反引号包裹。

  1. \\BEGIN 未非保留关键字,可以无需使用反引号包裹
  2. mysql> CREATE TABLE `select` (BEGIN int);
  3. Query OK, 0 rows affected (0.01 sec)

Note

与 MySQL 不同,在 MatrixOne 中,如果使用了限定符.,保留关键字如果不使用反引号包裹也会产生报错,建议在创建表和数据库时,避免使用保留关键字:

  1. mysql> CREATE TABLE test.select (BEGIN int);
  2. ERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 24 near "select (BEGIN int)";

保留关键字

A

  • ACCESSIBLE
  • ADD
  • ALL
  • ALTER
  • ANALYZE
  • AND
  • AS
  • ASC
  • ASENSITIVE

B

  • BEFORE
  • BEGIN
  • BETWEEN
  • BIGINT
  • BINARY
  • BLOB
  • BOTH
  • BY

C

  • CALL
  • CASCADE
  • CASE
  • CHANGE
  • CHAR
  • CHARACTER
  • CHECK
  • COLLATE
  • COLUMN
  • CONDITION
  • CONFIG
  • CONSTRAINT
  • CONTINUE
  • CONVERT
  • CREATE
  • CROSS
  • CURRENT_DATE
  • CURRENT_ROLE
  • CURRENT_TIME
  • CURRENT_TIMESTAMP
  • CURRENT_USER
  • CURSOR

D

  • DATABASE
  • DATABASES
  • DAY_HOUR
  • DAY_MICROSECOND
  • DAY_MINUTE
  • DAY_SECOND
  • DEC
  • DECIMAL
  • DECLARE
  • DEFAULT
  • DELAYED
  • DELETE
  • DENSE_RANK
  • DESC
  • DESCRIBE
  • DETERMINISTIC
  • DISTINCT
  • DISTINCTROW
  • DIV
  • DOUBLE
  • DROP

E

  • EACH
  • ELSE
  • ELSEIF
  • ENCLOSED
  • END
  • ESCAPE
  • ESCAPED
  • EXCEPT
  • EXISTS
  • EXIT
  • EXPLAIN

F

  • FALSE
  • FETCH
  • FLOAT
  • FLOAT4
  • FLOAT8
  • FOR
  • FORCE
  • FOREIGN
  • FROM
  • FULLTEXT
  • FUNCTION

G

  • GENERATED
  • GET
  • GRANT
  • GROUP
  • GROUPS

H

  • HAVING
  • HIGH_PRIORITY
  • HOUR_MICROSECOND
  • HOUR_MINUTE
  • HOUR_SECOND

I

  • IF
  • IGNORE
  • ILIKE
  • IN
  • INDEX
  • INFILE
  • INNER
  • INOUT
  • INSENSITIVE
  • INSERT
  • INT
  • INT1
  • INT2
  • INT3
  • INT4
  • INT8
  • INTEGER
  • INTERSECT
  • INTERVAL
  • INTO
  • IO_AFTER_GTIDS
  • IS
  • ITERATE

J

  • JOIN

K

  • KEY
  • KEYS
  • KILL

L

  • LEADING
  • LEAVE
  • LEFT
  • LIKE
  • LIMIT
  • LINEAR
  • LINES
  • LOAD
  • LOCALTIME
  • LOCALTIMESTAMP
  • LOCK
  • LONG
  • LONGBLOB
  • LONGTEXT
  • LOOP
  • LOW_PRIORITY

M

  • MASTER_BIND
  • MATCH
  • MAXVALUE
  • MEDIUMBLOB
  • MEDIUMINT
  • MEDIUMTEXT
  • MIDDLEINT
  • MINUS
  • MINUTE_MICROSECOND
  • MINUTE_SECOND
  • MOD
  • MODIFIES

N

  • NATURAL
  • NOT
  • NO_WRITE_TO_BINLOG
  • NULL
  • NUMERIC

O

  • ON
  • OPTIMIZE
  • OPTIMIZER_COSTS
  • OPTION
  • OPTIONALLY
  • OR
  • ORDER
  • OUT
  • OUTER
  • OUTFILE
  • OVER

P

  • PARTITION
  • PRECISION
  • PRIMARY
  • PROCEDURE

Q

  • QUICK

R

  • RANGE
  • RANK
  • READ
  • READS
  • READ_WRITE
  • REAL
  • RECURSIVE
  • REFERENCES
  • REGEXP
  • RELEASE
  • RENAME
  • REPEAT
  • REPLACE
  • REQUIRE
  • RESIGNAL
  • RESTRICT
  • RETURN
  • REVOKE
  • RIGHT
  • RLIKE
  • ROW
  • ROWS
  • ROW_NUMBER

S

  • SCHEMA
  • SCHEMAS
  • SECOND_MICROSECOND
  • SELECT
  • SENSITIVE
  • SEPARATOR
  • SET
  • SHOW
  • SIGNAL
  • SMALLINT
  • SPATIAL
  • SPECIFIC
  • SQL
  • SQLEXCEPTION
  • SQLSTATE
  • SQLWARNING
  • SQL_BIG_RESULT
  • SQL_BUFFER_RESULT
  • SQL_CALC_FOUND_ROWS
  • SQL_SMALL_RESULT
  • SSL
  • STARTING
  • STORED
  • STRAIGHT_JOIN

T

  • TABLE
  • TEMPORARY
  • TERMINATED
  • THEN
  • TINYBLOB
  • TINYINT
  • TINYTEXT
  • TO
  • TRAILING
  • TRIGGER
  • TRUE

U

  • UNDO
  • UNION
  • UNIQUE
  • UNLOCK
  • UNSIGNED
  • UNTIL
  • UPDATE
  • USAGE
  • USE
  • USING
  • UTC_DATE
  • UTC_TIME
  • UTC_TIMESTAMP

V

  • VALUES
  • VARBINARY
  • VARCHAR
  • VARCHARACTER
  • VARYING
  • VIRTUAL

W

  • WHEN
  • WHERE
  • WHILE
  • WITH
  • WRITE

X

  • XOR

Y

  • YEAR_MONTH

Z

  • ZEROFILL

非保留关键字

A

  • ACCOUNT
  • ACCOUNTS
  • ACTION
  • ADDDATE
  • ADMIN_NAME
  • AFTER
  • AGAINST
  • ALGORITHM
  • ANY
  • APPROX_COUNT
  • APPROX_COUNT_DISTINCT
  • APPROX_PERCENTILE
  • ASCII
  • ATTRIBUTE
  • AUTOEXTEND_SIZE
  • AUTO_INCREMENT
  • AUTO_RANDOM
  • AVG
  • AVG_ROW_LENGTH

B

  • BACKEND
  • BACKUP
  • BINDINGS
  • BIT
  • BIT_AND
  • BIT_CAST
  • BIT_OR
  • BOOL
  • BOOLEAN
  • BSI
  • BTREE

C

  • CANCEL
  • CASCADED
  • CAST
  • CHAIN
  • CHARSET
  • CHECKSUM
  • CIPHER
  • CLIENT
  • CLUSTER
  • CLUSTER_CENTERS
  • COALESCE
  • COLLATION
  • COLUMNS
  • COLUMN_FORMAT
  • COLUMN_NUMBER
  • COMMENT
  • COMMIT
  • COMMITTED
  • COMPACT
  • COMPRESSED
  • COMPRESSION
  • CONNECT
  • CONNECTION
  • CONNECTOR
  • CONNECTORS
  • CONSISTENT
  • COPY
  • COUNT
  • CREDENTIALS
  • CURDATE
  • CURRENT
  • CURRVAL
  • CURTIME
  • CYCLE

D

  • DAEMON
  • DATA
  • DATE
  • DATETIME
  • DATE_ADD
  • DATE_SUB
  • DAY
  • DEALLOCATE
  • DEFINER
  • DELAY_KEY_WRITE
  • DIRECTORY
  • DISABLE
  • DISCARD
  • DISK
  • DO
  • DRAINER
  • DUPLICATE
  • DYNAMIC

E

  • ENABLE
  • ENCRYPTION
  • ENFORCED
  • ENGINE
  • ENGINES
  • ENGINE_ATTRIBUTE
  • ENUM
  • ERRORS
  • EVENT
  • EVENTS
  • EXCLUSIVE
  • EXECUTE
  • EXPANSION
  • EXPIRE
  • EXTENDED
  • EXTENSION
  • EXTERNAL
  • EXTRACT

F

  • FAILED_LOGIN_ATTEMPTS
  • FIELDS
  • FILE
  • FILESYSTEM
  • FILL
  • FIRST
  • FIXED
  • FOLLOWING
  • FORCE_QUOTE
  • FORMAT
  • FULL

G

  • GEOMETRY
  • GEOMETRYCOLLECTION
  • GLOBAL
  • GRANTS
  • GROUP_CONCAT

H

  • HANDLER
  • HASH
  • HEADER
  • HEADERS
  • HISTORY
  • HOUR

I

  • IDENTIFIED
  • IMPORT
  • INCREMENT
  • INDEXES
  • INLINE
  • INPLACE
  • INSERT_METHOD
  • INSTANT
  • INVISIBLE
  • INVOKER
  • ISOLATION
  • ISSUER
  • IVFFLAT

J

  • JSON
  • JSONTYPE

K

  • KEY_BLOCK_SIZE

L

  • LANGUAGE
  • LAST
  • LASTVAL
  • LESS
  • LEVEL
  • LINESTRING
  • LIST
  • LISTS
  • LOCAL
  • LOCKS
  • LOW_CARDINALITY

M

  • MANAGE
  • MAX
  • MAX_CONNECTIONS_PER_HOUR
  • MAX_FILE_SIZE
  • MAX_QUERIES_PER_HOUR
  • MAX_ROWS
  • MAX_UPDATE_PER_HOUR
  • MAX_USER_CONNECTIONS
  • MEDIAN
  • MEMORY
  • MERGE
  • MICROSECOND
  • MID
  • MIN
  • MINUTE
  • MINVALUE
  • MIN_ROWS
  • MODE
  • MODIFY
  • MODUMP
  • MONTH
  • MULTILINESTRING
  • MULTIPOINT
  • MULTIPOLYGON
  • MYSQL_COMPATIBILITY_MODE

N

  • NAMES
  • NCHAR
  • NEVER
  • NEXT
  • NEXTVAL
  • NO
  • NODE
  • NONE
  • NOW
  • NULLS

O

  • OFFSET
  • ONLY
  • OPEN
  • OPTIONAL
  • OP_TYPE
  • OWNERSHIP

P

  • PACK_KEYS
  • PARALLEL
  • PARSER
  • PARTIAL
  • PARTITIONS
  • PASSWORD
  • PASSWORD_LOCK_TIME
  • PAUSE
  • PERCENT
  • PERSIST
  • PLUGINS
  • POINT
  • POLYGON
  • POSITION
  • PRECEDING
  • PREPARE
  • PREV
  • PRIVILEGES
  • PROCESSLIST
  • PROFILES
  • PROPERTIES
  • PROXY
  • PUBLICATION
  • PUBLICATIONS
  • PUMP

Q

  • QUARTER
  • QUERY
  • QUERY_RESULT

R

  • RANDOM
  • REDUNDANT
  • REFERENCE
  • REINDEX
  • RELOAD
  • REORGANIZE
  • REPAIR
  • REPEATABLE
  • REPLICATION
  • RESET
  • RESTRICTED
  • RESUME
  • RETURNS
  • REUSE
  • REVERSE
  • ROLE
  • ROLES
  • ROLLBACK
  • ROUTINE
  • ROW_COUNT
  • ROW_FORMAT
  • RTREE

S

  • S3OPTION
  • SAMPLE
  • SAN
  • SECOND
  • SECONDARY
  • SECONDARY_ENGINE_ATTRIBUTE
  • SECURITY
  • SEQUENCE
  • SEQUENCES
  • SERIALIZABLE
  • SERVERS
  • SESSION
  • SESSION_USER
  • SETVAL
  • SHARE
  • SHARED
  • SHUTDOWN
  • SIGNED
  • SIMPLE
  • SLAVE
  • SLIDING
  • SNAPSHOT
  • SOME
  • SOURCE
  • SPHERICAL_KMEANS
  • SQL_CACHE
  • SQL_NO_CACHE
  • SQL_TSI_DAY
  • SQL_TSI_HOUR
  • SQL_TSI_MINUTE
  • SQL_TSI_MONTH
  • SQL_TSI_QUARTER
  • SQL_TSI_SECOND
  • SQL_TSI_WEEK
  • SQL_TSI_YEAR
  • STAGE
  • STAGEOPTION
  • STAGES
  • START
  • STATS_AUTO_RECALC
  • STATS_PERSISTENT
  • STATS_SAMPLE_PAGES
  • STATUS
  • STD
  • STDDEV
  • STDDEV_POP
  • STDDEV_SAMP
  • STORAGE
  • STREAM
  • SUBDATE
  • SUBJECT
  • SUBPARTITION
  • SUBPARTITIONS
  • SUBSCRIPTIONS
  • SUBSTR
  • SUBSTRING
  • SUM
  • SUPER
  • SUSPEND
  • SYSDATE
  • SYSTEM_USER

T

  • TABLES
  • TABLESPACE
  • TABLE_NUMBER
  • TABLE_SIZE
  • TABLE_VALUES
  • TASK
  • TEMPTABLE
  • TEXT
  • THAN
  • TIME
  • TIMESTAMP
  • TIMESTAMPDIFF
  • TRANSACTION
  • TRANSLATE
  • TRIGGERS
  • TRIM
  • TRUNCATE
  • TYPE

U

  • UNBOUNDED
  • UNCOMMITTED
  • UNDEFINED
  • UNKNOWN
  • URL
  • USER
  • UUID

V

  • VALIDATION
  • VALUE
  • VARIABLES
  • VARIANCE
  • VAR_POP
  • VAR_SAMP
  • VECF32
  • VECF64
  • VERBOSE
  • VIEW
  • VISIBLE

W

  • WARNINGS
  • WEEK
  • WITHOUT
  • WORK

X

  • X509

Y

  • YEAR

Z

  • ZONEMAP

_

  • _BINARY