FLUSH TABLES

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

语法图

1. FlushStmt ::=
2. 'FLUSH' NoWriteToBinLogAliasOpt FlushOption

4. NoWriteToBinLogAliasOpt ::=
5. ( 'NO_WRITE_TO_BINLOG' | 'LOCAL' )?

7. FlushOption ::=
8. 'PRIVILEGES'
9. |   'STATUS'
10. |    'TIDB' 'PLUGINS' PluginNameList
11. |    'HOSTS'
12. |    LogTypeOpt 'LOGS'
13. |    TableOrTables TableNameListOpt WithReadLockOpt

15. LogTypeOpt ::=
16. ( 'BINARY' | 'ENGINE' | 'ERROR' | 'GENERAL' | 'SLOW' )?

18. TableOrTables ::=
19. 'TABLE'
20. |   'TABLES'

22. TableNameListOpt ::=
23. TableNameList?

25. WithReadLockOpt ::=
26. ( '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 来实现锁表。

另请参阅