FLUSH TABLES
FLUSH TABLES
语句用于提供 MySQL 兼容性,但在 TiDB 中并无有效用途。
语法图
FlushStmt
NoWriteToBinLogAliasOpt
FlushOption
LogTypeOpt
TableOrTables
TableNameListOpt
WithReadLockOpt
FlushStmt ::=
'FLUSH' NoWriteToBinLogAliasOpt FlushOption
NoWriteToBinLogAliasOpt ::=
( 'NO_WRITE_TO_BINLOG' | 'LOCAL' )?
FlushOption ::=
'PRIVILEGES'
| 'STATUS'
| 'TIDB' 'PLUGINS' PluginNameList
| 'HOSTS'
| LogTypeOpt 'LOGS'
| TableOrTables TableNameListOpt WithReadLockOpt
LogTypeOpt ::=
( 'BINARY' | 'ENGINE' | 'ERROR' | 'GENERAL' | 'SLOW' )?
TableOrTables ::=
'TABLE'
| 'TABLES'
TableNameListOpt ::=
TableNameList?
WithReadLockOpt ::=
( 'WITH' 'READ' 'LOCK' )?
示例
FLUSH TABLES;
Query OK, 0 rows affected (0.00 sec)
FLUSH TABLES WITH READ LOCK;
ERROR 1105 (HY000): FLUSH TABLES WITH READ LOCK is not supported. Please use @@tidb_snapshot
MySQL 兼容性
- TiDB 没有 MySQL 中的表缓存这一概念。所以,
FLUSH TABLES
因 MySQL 兼容性会在 TiDB 中解析出但会被忽略掉。 - 因为 TiDB 目前不支持锁表,所以
FLUSH TABLES WITH READ LOCK
语句会产生错误。建议使用 Historical reads 来实现锁表。