NULL
'
'a string' "another string"
'a string' 'a' ' ' 'string'
ANSI_QUOTES
binary
binary
COLLATE
[_charset_name
]'string
' [COLLATEcollation_name
]
SELECT _latin1'string
'; SELECT _binary'string
'; SELECT _utf8'string
' COLLATE utf8_danish_ci;
N'
literal
'literal
选择n'some文本;选择n'some文本;选择_utf8'some文本”;
NO_BACKSLASH_ESCAPES
\x
\b
B
character_set_connection
\Z
db_name
<file_name
\%
%
LIKE
\%
\%
%
'
''
"
""
\
'
"
SELECT
MySQL的> SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello';
------- --------- ----------- -------- -------- |你好|“你好”“你好”“| |来|你好| ------- --------- ----------- -------- -------- MySQL > SELECT "hello", "'hello'", "''hello''", "hel""lo", "\"hello";
| -------看书的阿| Hello Hello Hello |是是是是是是| HEL“| -------“Hello |看书的阿数据库 SELECT 'This\nIs\nFour\nLines';
-------------------- | thisisfourlines | -------------------- MySQL > SELECT 'disappearing\ backslash';
------------------------ |消失| ------------------------反斜杠
BLOB
NUL
NUL
mysql_real_escape_string_quote()
QUOTE()
DECIMAL
.
+
1
3.4
-6.78
1.2E3
-1.2E3
2.34
DECIMAL
DECIMAL
NUMERIC
DEC
FIXED
FLOAT
DOUBLE
FLOAT
DOUBLE
DOUBLE PRECISION
REAL
'2015-07-21'
20150721
DATE 'str
' TIME 'str
' TIMESTAMP 'str
'
{ d 'str
' } { t 'str
' } { ts 'str
' }
DATE
TIME
DATETIME
TIMESTAMP
DATETIME
DATETIME
TIMESTAMP
9999
TIMESTAMP
2038
DATE
'YYYY-MM-DD'
'2012-12-31'
'2012^12^31'
'YYYYMMDD'
'20070523'
'2007-05-23'
'0000-00-00'
YYYYMMDD
19830905
'1983-09-05'
DATETIME
TIMESTAMP
'YYYY-MM-DD
HH:MM:SS'
'2012-12-31 11:30:45'
'2012/12/31 11*30*45'
T
'2012-12-31T11:30:45'
'YYYYMMDDHHMMSS'
'20070523091528'
'2007-05-23 09:15:28'
'0000-00-00
00:00:00'
YYYYMMDDHHMMSS
19830905132800
'1983-09-05 13:28:00'
DATETIME
TIMESTAMP
70-99
00-69
10
'2015-06-09'
'2015-10-30
1:2:3'
YYYYMMDD
YYMMDD
'9903'
99
'1999-03-00'
TIME
'D HH:MM:SS'
'HH:MM:SS'
'D HH:MM'
'SS'
'HHMMSS'
'10:11:12'
'00:00:00'
HHMMSS
'10:11:12'
MMSS
'D HH:MM:SS.fraction'
'HHMMSS.fraction'
fraction
TIME
'8:3:2'
X'
val
'val
val
A..F
0x
X'01AF' X'01af' x'01AF' x'01af' 0x01AF 0x01af
X'0G' (G is not a hexadecimal digit) 0X01AF (0X must be written as 0x)
X'
val
'
MySQL的> SET @s = X'FFF';
错误1064(42000):你对你的SQL语法错误;检查对应于你的MySQL serverversion用近的x'fff ''mysql >正确的语法手册 SET @s = X'0FFF';
查询行,0行受影响(0秒)
0x
val
0xaaa
mysql>SELECT X'4D7953514C', CHARSET(X'4D7953514C');
+---------------+------------------------+ | X'4D7953514C' | CHARSET(X'4D7953514C') | +---------------+------------------------+ | MySQL | binary | +---------------+------------------------+ mysql>SELECT 0x5461626c65, CHARSET(0x5461626c65);
+--------------+-----------------------+ | 0x5461626c65 | CHARSET(0x5461626c65) | +--------------+-----------------------+ | Table | binary | +--------------+-----------------------+
COLLATE
[_charset_name
] X'val
' [COLLATEcollation_name
]
SELECT _latin1 X'4D7953514C'; SELECT _utf8 0x4D7953514C COLLATE utf8_danish_ci;
X'
val
'val
BIGINT
CAST(... AS UNSIGNED)
MySQL的> SET @v1 = X'41';
MySQL的> SET @v2 = X'41'+0;
MySQL的> SET @v3 = CAST(X'41' AS UNSIGNED);
MySQL的> SELECT @v1, @v2, @v3;
?????????| @ @ @ | | V1 V2 V3 |?????????|的| 65 65 | |?????????
X''
MySQL的> SELECT CHARSET(X''), LENGTH(X'');
-------------- ------------- |字符集(X’)|长度(X’)| -------------- ------------- |二进制| 0 | -------------- ------------- MySQL > SELECT X''+0;
------- | X”0 | ------- | 0 | -------
X'
val
'BLOB
HEX()
MySQL的> SELECT HEX('cat');
------------ |进制(猫的)| ------------ | 636174 | ------------ MySQL > SELECT X'636174';
----------- | X '636174”| ----------- |猫| -----------
_binary
MySQL的> SET @v1 = X'000D' | X'0BC0';
MySQL的> SET @v2 = _binary X'000D' | X'0BC0';
MySQL的> SELECT HEX(@v1), HEX(@v2);
————| HEX(十六进制(@ @ V1 V2)|)| ---------- ---------- | BCD | 0bcd | ---------- ----------
_binary
_binary
b'
val
'val
val
0b
b'01' B'01' 0b01
b'2' (2 is not a binary digit) 0B01 (0B must be written as 0b)
mysql>SELECT b'1000001', CHARSET(b'1000001');
+------------+---------------------+ | b'1000001' | CHARSET(b'1000001') | +------------+---------------------+ | A | binary | +------------+---------------------+ mysql>SELECT 0b1100001, CHARSET(0b1100001);
+-----------+--------------------+ | 0b1100001 | CHARSET(0b1100001) | +-----------+--------------------+ | a | binary | +-----------+--------------------+
COLLATE
[_charset_name
] b'val
' [COLLATEcollation_name
]
SELECT _latin1 b'1000001'; SELECT _utf8 0b1000001 COLLATE utf8_danish_ci;
b'
val
'val
CAST(... AS UNSIGNED)
MySQL的> SET @v1 = b'1100001';
MySQL的> SET @v2 = b'1100001'+0;
MySQL的> SET @v3 = CAST(b'1100001' AS UNSIGNED);
MySQL的> SELECT @v1, @v2, @v3;
------ ------ ------ | @ V1 V2 V3 | | @ @ | ------ ------ ------ |一| 97 | 97 | ------ ------ ------
b''
MySQL的> SELECT CHARSET(b''), LENGTH(b'');
-------------- ------------- |字符集(B’)|长度(B’)| -------------- ------------- |二进制| 0 | -------------- ------------- MySQL > SELECT b''+0;
------- | B”0 | ------- | 0 | -------
BIT
MySQL的> CREATE TABLE t (b BIT(8));
MySQL的> INSERT INTO t SET b = b'11111111';
MySQL的> INSERT INTO t SET b = b'1010';
MySQL的> INSERT INTO t SET b = b'0101';
BIN()
HEX()
MySQL的> SELECT b+0, BIN(b), OCT(b), HEX(b) FROM t;
------ ---------- -------- -------- | B 0 |仓(B)| OCT(B)|进制(B)| ------ ---------- -------- -------- | 255 | 11111111 | 377 | FF | | 10 | 1010 | 12 |一| | 5 | 101 | 5 | 5 | ------ ---------- -------- --------
_binary
MySQL的> SET @v1 = b'000010101' | b'000101010';
MySQL的> SET @v2 = _binary b'000010101' | _binary b'000101010';
MySQL的> SELECT HEX(@v1), HEX(@v2);
---------- ---------- |进制(@ V1)|进制(@ V2)| ---------- ---------- | 3f | 003f | ---------- ----------
_binary
_binary
NULL
NULL
NULL
LOAD DATA
INFILE
SELECT ... INTO
OUTFILE
\N
ORDER BY
`
MySQL的> SELECT * FROM `select` WHERE `select`.id > 100;
ANSI_QUOTES
MySQL的> CREATE TABLE "test" (col INT);
错误1064:你有一个错误在您的SQL语法…mysql > SET sql_mode='ANSI_QUOTES';
MySQL的> CREATE TABLE "test" (col INT);
查询行,0行受影响(0秒)
ANSI_QUOTES
a`b
mysql> CREATE TABLE `a``b` (`c"d` INT);
mysql> SELECT 1 AS `one`, 2 AS 'two';
+-----+-----+
| one | two |
+-----+-----+
| 1 | 2 |
+-----+-----+
M
eM
N
M
N
1e+3
1e+3
MD5()
CREATE
VIEW
mysql
t1
创建表T1(I型);
t1
db1.t1
创建表db1.t1(I型);
db1.t1
t1
.
tbl_name.col_name
tbl_name . col_name
`my-table`.`my-column`
CREATE DATABASE db1;
CREATE
创建表的表创建一个视图…;…;创建程序myproc…;创建函数MyFunc…;创建事件事件…;创建表创建视图mydb.myview mydb.mytable…;…;创建程序mydb.myproc…;创建功能mydb.myfunc…;创建事件mydb.myevent…;
CREATE TRIGGER mytrigger ... ON mytable ...; CREATE TRIGGER mytrigger ... ON mydb.mytable ...;
col_name | col_name |
tbl_name.col_name | col_name tbl_name |
db_name.tbl_name.col_name | col_name tbl_name db_name |
SELECT
SELECT c1 FROM mytableWHERE c2 > 100;SELECT mytable.c1 FROM mytableWHERE mytable.c2 > 100;SELECT mydb.mytable.c1 FROM mydb.mytableWHERE mydb.mytable.c2 > 100;
c1
c2
c
t2
t1.c
SELECT c1, c2, t1.c FROM t1 INNER JOIN t2 WHERE t2.c > 100;
t
t
c1
c2
c
db2.t
c1
SELECT c1, c2, db1.t.c FROM db1.t INNER JOIN db2.t WHERE db2.t.c > 100;
SELECT c1, c2, t1.c FROM db1.t AS t1 INNER JOIN db2.t AS t2 WHERE t2.c > 100;
lower_case_table_names
my_table
mysql> SELECT * FROM my_table WHERE MY_TABLE.col=1;
a
mysql>SELECT
->col_name
FROMtbl_name
AS aWHERE a.
col_name
= 1 OR A.col_name
= 2;
lower_case_table_names
lower_case_table_names
lower_case_table_names
lower_case_table_names
lower_case_table_names
0 | CREATE
TABLE CREATE
DATABASE --lower-case-table-names=0
|
1 | |
2 | CREATE
TABLE CREATE
DATABASE InnoDB lower_case_table_names=1 |
lower_case_table_names
MY_TABLE
lower_case_table_names=1
SHOW TABLES
SHOW DATABASES
lower_case_table_names=0
lower_case_table_names=2
InnoDB
lower_case_table_names=1
PREPARE
INFORMATION_SCHEMA
InnoDB
X'00'
a..zA..Z
_
5*20= 100 | |||||
5*20= 100 | |||||
20*7= 140 | |||||
20*2= 40 | |||||
20*1= 20 | |||||
20*11=220 | |||||
20*7= 140 | |||||
20*8= 160 | |||||
6*20= 120 | |||||
LATIN CAPITAL LETTER A WITH
GRAVE
LATIN SMALL LETTER A WITH GRAVE
G
_
0x003F -> @003f 0xFFFF -> @ffff
ucs2
nul
aux
IGNORE_SPACE
count
select count(*)从mytable;创建表的计数(I型);
(
COUNT
SYM_FN()
IGNORE_SPACE
BIT_AND
BIT_OR
BIT_XOR
CAST
COUNT
CURDATE
CURTIME
DATE_ADD
DATE_SUB
EXTRACT
GROUP_CONCAT
MAX
MID
MIN
NOW
POSITION
STD
STDDEV
STDDEV_POP
STDDEV_SAMP
SUBSTR
SUBSTRING
SUM
SYSDATE
TRIM
VARIANCE
VAR_POP
VAR_SAMP
sql/lex.h
func_name
()func_name
IGNORE_SPACE
IGNORE_SPACE
MySQL的> CREATE TABLE count(i INT);
错误1064(42000):你有一个错误在您的SQL语法…近数(I型)”
CREATE TABLE count (i INT); CREATE TABLE `count`(i INT); CREATE TABLE `count` (i INT);
IGNORE_SPACE
select count(*)从mytable;select count(*)从mytable;
IGNORE_SPACE
IGNORE_SPACE
CREATE TABLE count(i INT); CREATE TABLE count (i INT);
CREATE TABLE `count`(i INT); CREATE TABLE `count` (i INT);
IGNORE_SPACE
SET sql_mode = 'IGNORE_SPACE';
IGNORE_SPACE
ANSI
SET sql_mode = 'ANSI';
IGNORE_SPACE
IGNORE_SPACE
count
IGNORE_SPACE
IGNORE_SPACE
创建表的计数(I型);创建表的计数(I型);
CREATE TABLE `count`(i INT); CREATE TABLE `count` (i INT);
PI
test.PI()
PI()
SHOW
WARNINGS
DROP FUNCTION
CREATE FUNCTION
schema_name
.func_name
()
SELECT
DELETE
BIGINT
mysql> CREATE TABLE interval (begin INT, end INT);
ERROR 1064 (42000): You have an error in your SQL syntax ...
near 'interval (begin INT, end INT)'
BEGIN
INTERVAL
MySQL的> CREATE TABLE `interval` (begin INT, end INT);
查询好,为受影响的行(0.01秒)
mysql> CREATE TABLE mydb.interval (begin INT, end INT);
Query OK, 0 rows affected (0.01 sec)
COUNT
INFORMATION_SCHEMA.KEYWORDS
_FILENAME
GROUP
ACCESSIBLE
ACCOUNT
ACTION
ACTIVE
ADD
ADMIN
AFTER
AGAINST
AGGREGATE
ALGORITHM
ALL
ALTER
ALWAYS
ANALYSE
ANALYZE
AND
ANY
AS
ASC
ASCII
ASENSITIVE
AT
AUTOEXTEND_SIZE
AUTO_INCREMENT
AVG
AVG_ROW_LENGTH
BACKUP
BEFORE
BEGIN
BETWEEN
BIGINT
BINARY
BINLOG
BIT
BLOB
BLOCK
BOOL
BOOLEAN
BOTH
BTREE
BUCKETS
BY
BYTE
CACHE
CALL
CASCADE
CASCADED
CASE
CATALOG_NAME
CHAIN
CHANGE
CHANGED
CHANNEL
CHAR
CHARACTER
CHARSET
CHECK
CHECKSUM
CIPHER
CLASS_ORIGIN
CLIENT
CLONE
CLOSE
COALESCE
CODE
COLLATE
COLLATION
COLUMN
COLUMNS
COLUMN_FORMAT
COLUMN_NAME
COMMENT
COMMIT
COMMITTED
COMPACT
COMPLETION
COMPONENT
COMPRESSED
COMPRESSION
CONCURRENT
CONDITION
CONNECTION
CONSISTENT
CONSTRAINT
CONSTRAINT_CATALOG
CONSTRAINT_NAME
CONSTRAINT_SCHEMA
CONTAINS
CONTEXT
CONTINUE
CONVERT
CPU
CREATE
CROSS
CUBE
CUME_DIST
CURRENT
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_USER
CURSOR
CURSOR_NAME
DATA
DATABASE
DATABASES
DATAFILE
DATE
DATETIME
DAY
DAY_HOUR
DAY_MICROSECOND
DAY_MINUTE
DAY_SECOND
DEALLOCATE
DEC
DECIMAL
DECLARE
DEFAULT
DEFAULT_AUTH
DEFINER
DEFINITION
DELAYED
DELAY_KEY_WRITE
DELETE
DENSE_RANK
DESC
DESCRIBE
DESCRIPTION
DES_KEY_FILE
DETERMINISTIC
DIAGNOSTICS
DIRECTORY
DISABLE
DISCARD
DISK
DISTINCT
DISTINCTROW
DIV
DO
DOUBLE
DROP
DUAL
DUMPFILE
DUPLICATE
DYNAMIC
EACH
ELSE
ELSEIF
EMPTY
ENABLE
ENCLOSED
ENCRYPTION
END
ENDS
ENGINE
ENGINES
ENUM
ERROR
ERRORS
ESCAPE
ESCAPED
EVENT
EVENTS
EVERY
EXCEPT
EXCHANGE
EXCLUDE
EXECUTE
EXISTS
EXIT
EXPANSION
EXPIRE
EXPLAIN
EXPORT
EXTENDED
EXTENT_SIZE
FALSE
FAST
FAULTS
FETCH
FIELDS
FILE
FILE_BLOCK_SIZE
FILTER
FIRST
FIRST_VALUE
FIXED
FLOAT
FLOAT4
FLOAT8
FLUSH
FOLLOWING
FOLLOWS
FOR
FORCE
FOREIGN
FORMAT
FOUND
FROM
FULL
FULLTEXT
FUNCTION
GENERAL
GENERATED
GEOMCOLLECTION
GEOMETRY
GEOMETRYCOLLECTION
GET
GET_FORMAT
GET_MASTER_PUBLIC_KEY
GLOBAL
GRANT
GRANTS
GROUP
GROUPING
GROUPS
GROUP_REPLICATION
HANDLER
HASH
HAVING
HELP
HIGH_PRIORITY
HISTOGRAM
HISTORY
HOST
HOSTS
HOUR
HOUR_MICROSECOND
HOUR_MINUTE
HOUR_SECOND
IDENTIFIED
IF
IGNORE
IGNORE_SERVER_IDS
IMPORT
IN
INACTIVE
INDEX
INDEXES
INFILE
INITIAL_SIZE
INNER
INOUT
INSENSITIVE
INSERT
INSERT_METHOD
INSTALL
INSTANCE
INT
INT1
INT2
INT3
INT4
INT8
INTEGER
INTERVAL
INTO
INVISIBLE
INVOKER
IO
IO_AFTER_GTIDS
IO_BEFORE_GTIDS
IO_THREAD
IPC
IS
ISOLATION
ISSUER
ITERATE
JOIN
JSON
JSON_TABLE
KEY
KEYS
KEY_BLOCK_SIZE
KILL
LAG
LANGUAGE
LAST
LAST_VALUE
LEAD
LEADING
LEAVE
LEAVES
LEFT
LESS
LEVEL
LIKE
LIMIT
LINEAR
LINES
LINESTRING
LIST
LOAD
LOCAL
LOCALTIME
LOCALTIMESTAMP
LOCK
LOCKED
LOCKS
LOGFILE
LOGS
LONG
LONGBLOB
LONGTEXT
LOOP
LOW_PRIORITY
MASTER
MASTER_AUTO_POSITION
MASTER_BIND
MASTER_CONNECT_RETRY
MASTER_DELAY
MASTER_HEARTBEAT_PERIOD
MASTER_HOST
MASTER_LOG_FILE
MASTER_LOG_POS
MASTER_PASSWORD
MASTER_PORT
MASTER_PUBLIC_KEY_PATH
MASTER_RETRY_COUNT
MASTER_SERVER_ID
MASTER_SSL
MASTER_SSL_CA
MASTER_SSL_CAPATH
MASTER_SSL_CERT
MASTER_SSL_CIPHER
MASTER_SSL_CRL
MASTER_SSL_CRLPATH
MASTER_SSL_KEY
MASTER_SSL_VERIFY_SERVER_CERT
MASTER_TLS_VERSION
MASTER_USER
MATCH
MAXVALUE
MAX_CONNECTIONS_PER_HOUR
MAX_QUERIES_PER_HOUR
MAX_ROWS
MAX_SIZE
MAX_UPDATES_PER_HOUR
MAX_USER_CONNECTIONS
MEDIUM
MEDIUMBLOB
MEDIUMINT
MEDIUMTEXT
MEMORY
MERGE
MESSAGE_TEXT
MICROSECOND
MIDDLEINT
MIGRATE
MINUTE
MINUTE_MICROSECOND
MINUTE_SECOND
MIN_ROWS
MOD
MODE
MODIFIES
MODIFY
MONTH
MULTILINESTRING
MULTIPOINT
MULTIPOLYGON
MUTEX
MYSQL_ERRNO
NAME
NAMES
NATIONAL
NATURAL
NCHAR
NDB
NDBCLUSTER
NESTED
NEVER
NEW
NEXT
NO
NODEGROUP
NONE
NOT
NOWAIT
NO_WAIT
NO_WRITE_TO_BINLOG
NTH_VALUE
NTILE
NULL
NULLS
NUMBER
NUMERIC
NVARCHAR
OF
OFFSET
ON
ONE
ONLY
OPEN
OPTIMIZE
OPTIMIZER_COSTS
OPTION
OPTIONAL
OPTIONALLY
OPTIONS
OR
ORDER
ORDINALITY
ORGANIZATION
OTHERS
OUT
OUTER
OUTFILE
OVER
OWNER
PACK_KEYS
PAGE
PARSER
PARTIAL
PARTITION
PARTITIONING
PARTITIONS
PASSWORD
PATH
PERCENT_RANK
PERSIST
PERSIST_ONLY
PHASE
PLUGIN
PLUGINS
PLUGIN_DIR
POINT
POLYGON
PORT
PRECEDES
PRECEDING
PRECISION
PREPARE
PRESERVE
PREV
PRIMARY
PRIVILEGES
PROCEDURE
PROCESS
PROCESSLIST
PROFILE
PROFILES
PROXY
PURGE
QUARTER
QUERY
QUICK
RANGE
RANK
READ
READS
READ_ONLY
READ_WRITE
REAL
REBUILD
RECOVER
RECURSIVE
REDOFILE
REDO_BUFFER_SIZE
REDUNDANT
REFERENCE
REFERENCES
REGEXP
RELAY
RELAYLOG
RELAY_LOG_FILE
RELAY_LOG_POS
RELAY_THREAD
RELEASE
RELOAD
REMOTE
REMOVE
RENAME
REORGANIZE
REPAIR
REPEAT
REPEATABLE
REPLACE
REPLICATE_DO_DB
REPLICATE_DO_TABLE
REPLICATE_IGNORE_DB
REPLICATE_IGNORE_TABLE
REPLICATE_REWRITE_DB
REPLICATE_WILD_DO_TABLE
REPLICATE_WILD_IGNORE_TABLE
REPLICATION
REQUIRE
RESET
RESIGNAL
RESOURCE
RESPECT
RESTART
RESTORE
RESTRICT
RESUME
RETURN
RETURNED_SQLSTATE
RETURNS
REUSE
REVERSE
REVOKE
RIGHT
RLIKE
ROLE
ROLLBACK
ROLLUP
ROTATE
ROUTINE
ROW
ROWS
ROW_COUNT
ROW_FORMAT
ROW_NUMBER
RTREE
SAVEPOINT
SCHEDULE
SCHEMA
SCHEMAS
SCHEMA_NAME
SECOND
SECONDARY_ENGINE
SECONDARY_LOAD
SECONDARY_UNLOAD
SECOND_MICROSECOND
SECURITY
SELECT
SENSITIVE
SEPARATOR
SERIAL
SERIALIZABLE
SERVER
SESSION
SET
SHARE
SHOW
SHUTDOWN
SIGNAL
SIGNED
SIMPLE
SKIP
SLAVE
SLOW
SMALLINT
SNAPSHOT
SOCKET
SOME
SONAME
SOUNDS
SOURCE
SPATIAL
SPECIFIC
SQL
SQLEXCEPTION
SQLSTATE
SQLWARNING
SQL_AFTER_GTIDS
SQL_AFTER_MTS_GAPS
SQL_BEFORE_GTIDS
SQL_BIG_RESULT
SQL_BUFFER_RESULT
SQL_CACHE
SQL_CALC_FOUND_ROWS
SQL_NO_CACHE
SQL_SMALL_RESULT
SQL_THREAD
SQL_TSI_DAY
SQL_TSI_HOUR
SQL_TSI_MINUTE
SQL_TSI_MONTH
SQL_TSI_QUARTER
SQL_TSI_SECOND
SQL_TSI_WEEK
SQL_TSI_YEAR
SRID
SSL
STACKED
START
STARTING
STARTS
STATS_AUTO_RECALC
STATS_PERSISTENT
STATS_SAMPLE_PAGES
STATUS
STOP
STORAGE
STORED
STRAIGHT_JOIN
STRING
SUBCLASS_ORIGIN
SUBJECT
SUBPARTITION
SUBPARTITIONS
SUPER
SUSPEND
SWAPS
SWITCHES
SYSTEM
TABLE
TABLES
TABLESPACE
TABLE_CHECKSUM
TABLE_NAME
TEMPORARY
TEMPTABLE
TERMINATED
TEXT
THAN
THEN
THREAD_PRIORITY
TIES
TIME
TIMESTAMP
TIMESTAMPADD
TIMESTAMPDIFF
TINYBLOB
TINYINT
TINYTEXT
TO
TRAILING
TRANSACTION
TRIGGER
TRIGGERS
TRUE
TRUNCATE
TYPE
TYPES
UNBOUNDED
UNCOMMITTED
UNDEFINED
UNDO
UNDOFILE
UNDO_BUFFER_SIZE
UNICODE
UNINSTALL
UNION
UNIQUE
UNKNOWN
UNLOCK
UNSIGNED
UNTIL
UPDATE
UPGRADE
USAGE
USE
USER
USER_RESOURCES
USE_FRM
USING
UTC_DATE
UTC_TIME
UTC_TIMESTAMP
VALIDATION
VALUE
VALUES
VARBINARY
VARCHAR
VARCHARACTER
VARIABLES
VARYING
VCPU
VIEW
VIRTUAL
VISIBLE
WAIT
WARNINGS
WEEK
WEIGHT_STRING
WHEN
WHERE
WHILE
WINDOW
WITH
WITHOUT
WORK
WRAPPER
WRITE
X509
XA
XID
XML
XOR
YEAR
YEAR_MONTH
ZEROFILL
ACTIVE
ADMIN
BUCKETS
CLONE
COMPONENT
CUME_DIST
DEFINITION
DENSE_RANK
DESCRIPTION
EMPTY
EXCEPT
EXCLUDE
FIRST_VALUE
FOLLOWING
GEOMCOLLECTION
GET_MASTER_PUBLIC_KEY
GROUPING
GROUPS
HISTOGRAM
HISTORY
INACTIVE
INVISIBLE
JSON_TABLE
LAG
LAST_VALUE
LEAD
LOCKED
MASTER_PUBLIC_KEY_PATH
NESTED
NOWAIT
NTH_VALUE
NTILE
NULLS
OF
OPTIONAL
ORDINALITY
ORGANIZATION
OTHERS
OVER
PATH
PERCENT_RANK
PERSIST
PERSIST_ONLY
PRECEDING
PROCESS
RANK
RECURSIVE
REFERENCE
RESOURCE
RESPECT
RESTART
REUSE
ROLE
ROW_NUMBER
SECONDARY_ENGINE
SECONDARY_LOAD
SECONDARY_UNLOAD
SKIP
SRID
SYSTEM
THREAD_PRIORITY
TIES
UNBOUNDED
VCPU
VISIBLE
WINDOW
@
var_name
var_name
_
@'my-var'
@`my-var`
user_variables_by_thread
SET
设置” var_name
=expr
[,@ var_name
=expr
]…
SET
:=
=
=
SET
MySQL的> SET @t1=1, @t2=2, @t3:=4;
MySQL的> SELECT @t1, @t2, @t3, @t4 := @t1+@t2+@t3;
+------+------+------+--------------------+| @t1 | @t2 | @t3 | @t4 := @t1+@t2+@t3 |+------+------+------+--------------------+| 1 | 2 | 4 | 7 |+------+------+------+--------------------+
NULL
JSON
utf8mb4_bin
CAST(... AS UNSIGNED)
MySQL的> SET @v1 = X'41';
MySQL的> SET @v2 = X'41'+0;
MySQL的> SET @v3 = CAST(X'41' AS UNSIGNED);
MySQL的> SELECT @v1, @v2, @v3;
——————| @ @ | V1 V2 V3 | |”——————| A | | 65 65 |——————MySQL > SET @v1 = b'1000001';
MySQL的> SET @v2 = b'1000001'+0;
MySQL的> SET @v3 = CAST(b'1000001' AS UNSIGNED);
MySQL的> SELECT @v1, @v2, @v3;
?????????| @ @ @ | | V1 V2 V3 |?????????|的| 65 65 | |?????????
NULL
LIMIT
SELECT
N
LOAD DATA
SET
SET @a = @a + 1;
SELECT
SELECT @a, @a:=@a+1, ...;
SET
MySQL的> SET @a='test';
MySQL的> SELECT @a,(@a:=20) FROM
tbl_name
;
SELECT
SELECT
0
''
SELECT
GROUP BY
mysql> SELECT (@aa:=id) AS a, (@aa+3) AS b FROM tbl_name
HAVING b=5;
b
@aa
id
SELECT
MySQL的> SELECT c1 FROM t;
---- | C1 | ---- | 0 | ---- | 1 | ----两排在集(0.001秒)MySQL > SET @col = "c1";
查询行,0行受影响(0秒)MySQL > SELECT @col FROM t;
------ | @西| ------ | C1 | ------ 1行集(0秒)MySQL > SELECT `@col` FROM t;
error unknown column(42s22 1054):@在场的列表 mysql> SET @col = "`c1`";Query OK, 0 rows affected (0.00 sec)mysql>SELECT @col FROM t;
------ | @西| ------ | ` C1 ` | ------ 1行集(0秒)
mysql>SET @c = "c1";
Query OK, 0 rows affected (0.00 sec) mysql>SET @s = CONCAT("SELECT ", @c, " FROM t");
Query OK, 0 rows affected (0.00 sec) mysql>PREPARE stmt FROM @s;
Query OK, 0 rows affected (0.04 sec) Statement prepared mysql>EXECUTE stmt;
+----+ | c1 | +----+ | 0 | +----+ | 1 | +----+ 2 rows in set (0.00 sec) mysql>DEALLOCATE PREPARE stmt;
Query OK, 0 rows affected (0.00 sec)
<?php $mysqli = new mysqli("localhost", "user", "pass", "test"); if( mysqli_connect_errno() ) die("Connection failed: %s\n", mysqli_connect_error()); $col = "c1"; $query = "SELECT $col FROM t"; $result = $mysqli->query($query); while($row = $result->fetch_assoc()) { echo "<p>" . $row["$col"] . "</p>\n"; } $result->close(); $mysqli->close(); ?>
sql/sql_yacc.yy
expr
: expr
或 expr
| expr
| | expr
| expr
异或 expr
| expr
和 expr
| expr
& expr
|不 expr
|! expr
| boolean_primary
是[不] {真|假|未知} | boolean_primary
boolean_primary
: boolean_primary
是[不]空| boolean_primary
<=>predicate
| boolean_primary
comparison_operator
predicate
| boolean_primary
comparison_operator
{有}(所有| subquery
)| predicate
comparison_operator
: = | >= | > | <= | < | <> | !=predicate
: bit_expr
[注释]和( subquery
)| bit_expr
[注释]和( expr
【, expr
| ]…) bit_expr
[不]之间 bit_expr
和 predicate
| bit_expr
听起来像 bit_expr
| bit_expr
[不]像 simple_expr
翼虎 simple_expr
| ] bit_expr
[不]正则表达式 bit_expr
| bit_expr
bit_expr
: bit_expr
| bit_expr
| bit_expr
& bit_expr
| bit_expr
<<bit_expr
| bit_expr
>>bit_expr
| bit_expr
bit_expr
| bit_expr
— bit_expr
| bit_expr
* bit_expr
| bit_expr
/ bit_expr
| bit_expr
DIV bit_expr
| bit_expr
国防部 bit_expr
| bit_expr
% bit_expr
| bit_expr
^ bit_expr
| bit_expr
interval_expr
| bit_expr
— interval_expr
| simple_expr
simple_expr
: literal
| identifier
| function_call
| simple_expr
整理 collation_name
| param_marker
| variable
| simple_expr
| | simple_expr
| simple_expr
|— simple_expr
| ~ simple_expr
|! simple_expr
|二进制 simple_expr
|( expr
【, expr
| row()]…… expr
, expr
【, expr
] |(…) subquery
| exists() subquery
)| { identifier
expr
} | match_expr
| case_expr
| interval_expr
param_marker
(
subquery
)
{
identifier
expr
}expr
match_expr
MATCH
case_expr
CASE
interval_expr
expr
unit
unit
DAY
unit
DATE_ADD()
||
OR
PIPES_AS_CONCAT
||
^
!
HIGH_NOT_PRECEDENCE
!
#
--
/*
mysql>SELECT 1+1; # This comment continues to the end of line
mysql>SELECT 1+1; -- This comment continues to the end of line
mysql>SELECT 1 /* this is an in-line comment */ + 1;
mysql>SELECT 1+
/*
this is a
multiple-line comment
*/
1;
/*! MySQL-specific code
*/
STRAIGHT_JOIN
选择/ *!straight_join * / 2从表1,表2…
!
CREATE TABLE t1(a INT, KEY (a)) /*!50110 KEY_BLOCK_SIZE=1024 */;
/*!12345 ... */
+
SELECT /*+ BKA(t1) */ FROM ... ;
\C