FLUSH TABLES

FLUSH TABLES 语句用于提供 MySQL 兼容性,但在 TiDB 中并无有效用途。

语法图

FlushStmt

FLUSH TABLES - 图1

NoWriteToBinLogAliasOpt

FLUSH TABLES - 图2

FlushOption

FLUSH TABLES - 图3

LogTypeOpt

FLUSH TABLES - 图4

TableOrTables

FLUSH TABLES - 图5

TableNameListOpt

FLUSH TABLES - 图6

WithReadLockOpt

FLUSH TABLES - 图7

  1. FlushStmt ::=
  2. 'FLUSH' NoWriteToBinLogAliasOpt FlushOption
  3. NoWriteToBinLogAliasOpt ::=
  4. ( 'NO_WRITE_TO_BINLOG' | 'LOCAL' )?
  5. FlushOption ::=
  6. 'PRIVILEGES'
  7. | 'STATUS'
  8. | 'TIDB' 'PLUGINS' PluginNameList
  9. | 'HOSTS'
  10. | LogTypeOpt 'LOGS'
  11. | TableOrTables TableNameListOpt WithReadLockOpt
  12. LogTypeOpt ::=
  13. ( 'BINARY' | 'ENGINE' | 'ERROR' | 'GENERAL' | 'SLOW' )?
  14. TableOrTables ::=
  15. 'TABLE'
  16. | 'TABLES'
  17. TableNameListOpt ::=
  18. TableNameList?
  19. WithReadLockOpt ::=
  20. ( 'WITH' 'READ' 'LOCK' )?

示例

  1. FLUSH TABLES;
  1. Query OK, 0 rows affected (0.00 sec)
  1. FLUSH TABLES WITH READ LOCK;
  1. 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 来实现锁表。

另请参阅