Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 1.51 KB

sql-statement-flush-tables.md

File metadata and controls

71 lines (50 loc) · 1.51 KB
title summary aliases
FLUSH TABLES
TiDB 数据库中 FLUSH TABLES 的使用概况。
/docs-cn/dev/sql-statements/sql-statement-flush-tables/
/docs-cn/dev/reference/sql/statements/flush-tables/

FLUSH TABLES

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

语法图

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' )?

示例

{{< copyable "sql" >}}

FLUSH TABLES;
Query OK, 0 rows affected (0.00 sec)

{{< copyable "sql" >}}

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 来实现锁表。

另请参阅