From 063ebecf48054ed807c0919e9196e871416004c6 Mon Sep 17 00:00:00 2001 From: 0xPoe Date: Tue, 7 Oct 2025 15:05:24 +0200 Subject: [PATCH 01/17] tidb: add the refresh stats statement fix: update warnings Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> fix: remove unnessary part fix: update privileges fix: correct the link fix: update link style fix: make lint happy fix: make lint happy fix : make lint happy --- TOC.md | 1 + sql-statements/sql-statement-overview.md | 455 +++++++++--------- sql-statements/sql-statement-refresh-stats.md | 98 ++++ 3 files changed, 327 insertions(+), 227 deletions(-) create mode 100644 sql-statements/sql-statement-refresh-stats.md diff --git a/TOC.md b/TOC.md index 3aba0440ea012..44a57aab36ef7 100644 --- a/TOC.md +++ b/TOC.md @@ -864,6 +864,7 @@ - [`PREPARE`](/sql-statements/sql-statement-prepare.md) - [`QUERY WATCH`](/sql-statements/sql-statement-query-watch.md) - [`RECOVER TABLE`](/sql-statements/sql-statement-recover-table.md) + - [`REFRESH STATS`](/sql-statements/sql-statement-refresh-stats.md) - [`RENAME USER`](/sql-statements/sql-statement-rename-user.md) - [`RENAME TABLE`](/sql-statements/sql-statement-rename-table.md) - [`REPLACE`](/sql-statements/sql-statement-replace.md) diff --git a/sql-statements/sql-statement-overview.md b/sql-statements/sql-statement-overview.md index c76059777c72d..bf80964376d5f 100644 --- a/sql-statements/sql-statement-overview.md +++ b/sql-statements/sql-statement-overview.md @@ -9,222 +9,222 @@ TiDB uses SQL statements that aim to follow ISO/IEC SQL standards, with extensio ## Schema management / Data definition statements (DDL) -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER DATABASE`](/sql-statements/sql-statement-alter-database.md) | Modifies a database. | -| [`ALTER SEQUENCE`](/sql-statements/sql-statement-alter-sequence.md) | Modifies a sequence. | -| [`ALTER TABLE ... ADD COLUMN`](/sql-statements/sql-statement-add-column.md) | Adds a column to an existing table. | -| [`ALTER TABLE ... ADD INDEX`](/sql-statements/sql-statement-add-index.md) | Adds an index to an existing table. | -| [`ALTER TABLE ... ALTER INDEX`](/sql-statements/sql-statement-alter-index.md) | Changes an index definition. | -| [`ALTER TABLE ... CHANGE COLUMN`](/sql-statements/sql-statement-change-column.md) | Changes a column definition. | -| [`ALTER TABLE ... COMPACT`](/sql-statements/sql-statement-alter-table-compact.md) | Compacts a table. | -| [`ALTER TABLE ... DROP COLUMN`](/sql-statements/sql-statement-drop-column.md) | Drops a column from a table. | -| [`ALTER TABLE ... MODIFY COLUMN`](/sql-statements/sql-statement-modify-column.md) | Modifies a column definition. | -| [`ALTER TABLE ... RENAME INDEX`](/sql-statements/sql-statement-rename-index.md) | Renames an index. | -| [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md) | Changes a table definition. | -| [`CREATE DATABASE`](/sql-statements/sql-statement-create-database.md) | Creates a new database. | -| [`CREATE INDEX`](/sql-statements/sql-statement-create-index.md) | Creates a new index on a table. | -| [`CREATE SEQUENCE`](/sql-statements/sql-statement-create-sequence.md) | Creates a new sequence object. | -| [`CREATE TABLE LIKE`](/sql-statements/sql-statement-create-table-like.md) | Copies the definition of an existing table, without copying any data. | -| [`CREATE TABLE`](/sql-statements/sql-statement-create-table.md) | Creates a new table. | -| [`CREATE VIEW`](/sql-statements/sql-statement-create-view.md) | Creates a new view. | -| [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md) | Drops an existing database. | -| [`DROP INDEX`](/sql-statements/sql-statement-drop-index.md) | Drops an index from a table. | -| [`DROP SEQUENCE`](/sql-statements/sql-statement-drop-sequence.md) | Drops a sequence object. | -| [`DROP TABLE`](/sql-statements/sql-statement-drop-table.md) | Drops an existing table. | -| [`DROP VIEW`](/sql-statements/sql-statement-drop-view.md) | Drops an existing view. | -| [`RENAME TABLE`](/sql-statements/sql-statement-rename-table.md) | Renames a table. | -| [`SHOW COLUMNS FROM`](/sql-statements/sql-statement-show-columns-from.md) | Shows the columns from a table. | -| [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md) | Shows the CREATE statement for a database. | -| [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md) | Shows the CREATE statement for a sequence. | -| [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md) | Shows the CREATE statement for a table. | -| [`SHOW DATABASES`](/sql-statements/sql-statement-show-databases.md) | Shows a list of databases that the current user has privileges to. | -| [`SHOW FIELDS FROM`](/sql-statements/sql-statement-show-fields-from.md) | Shows columns of a table. | -| [`SHOW INDEXES`](/sql-statements/sql-statement-show-indexes.md) | Shows indexes of a table. | -| [`SHOW SCHEMAS`](/sql-statements/sql-statement-show-schemas.md) | An alias to `SHOW DATABASES`, which shows a list of databases that the current user has privileges to. | -| [`SHOW TABLE NEXT_ROW_ID`](/sql-statements/sql-statement-show-table-next-rowid.md) | Shows the next row ID for a table. | -| [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md) | Shows the Region information of a table in TiDB. | -| [`SHOW TABLE STATUS`](/sql-statements/sql-statement-show-table-status.md) | Shows various statistics about tables in TiDB. | -| [`SHOW TABLES`](/sql-statements/sql-statement-show-tables.md) | Shows tables in a database. | -| [`TRUNCATE`](/sql-statements/sql-statement-truncate.md) | Truncates all data from a table. | +| SQL Statement | Description | +| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | +| [`ALTER DATABASE`](/sql-statements/sql-statement-alter-database.md) | Modifies a database. | +| [`ALTER SEQUENCE`](/sql-statements/sql-statement-alter-sequence.md) | Modifies a sequence. | +| [`ALTER TABLE ... ADD COLUMN`](/sql-statements/sql-statement-add-column.md) | Adds a column to an existing table. | +| [`ALTER TABLE ... ADD INDEX`](/sql-statements/sql-statement-add-index.md) | Adds an index to an existing table. | +| [`ALTER TABLE ... ALTER INDEX`](/sql-statements/sql-statement-alter-index.md) | Changes an index definition. | +| [`ALTER TABLE ... CHANGE COLUMN`](/sql-statements/sql-statement-change-column.md) | Changes a column definition. | +| [`ALTER TABLE ... COMPACT`](/sql-statements/sql-statement-alter-table-compact.md) | Compacts a table. | +| [`ALTER TABLE ... DROP COLUMN`](/sql-statements/sql-statement-drop-column.md) | Drops a column from a table. | +| [`ALTER TABLE ... MODIFY COLUMN`](/sql-statements/sql-statement-modify-column.md) | Modifies a column definition. | +| [`ALTER TABLE ... RENAME INDEX`](/sql-statements/sql-statement-rename-index.md) | Renames an index. | +| [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md) | Changes a table definition. | +| [`CREATE DATABASE`](/sql-statements/sql-statement-create-database.md) | Creates a new database. | +| [`CREATE INDEX`](/sql-statements/sql-statement-create-index.md) | Creates a new index on a table. | +| [`CREATE SEQUENCE`](/sql-statements/sql-statement-create-sequence.md) | Creates a new sequence object. | +| [`CREATE TABLE LIKE`](/sql-statements/sql-statement-create-table-like.md) | Copies the definition of an existing table, without copying any data. | +| [`CREATE TABLE`](/sql-statements/sql-statement-create-table.md) | Creates a new table. | +| [`CREATE VIEW`](/sql-statements/sql-statement-create-view.md) | Creates a new view. | +| [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md) | Drops an existing database. | +| [`DROP INDEX`](/sql-statements/sql-statement-drop-index.md) | Drops an index from a table. | +| [`DROP SEQUENCE`](/sql-statements/sql-statement-drop-sequence.md) | Drops a sequence object. | +| [`DROP TABLE`](/sql-statements/sql-statement-drop-table.md) | Drops an existing table. | +| [`DROP VIEW`](/sql-statements/sql-statement-drop-view.md) | Drops an existing view. | +| [`RENAME TABLE`](/sql-statements/sql-statement-rename-table.md) | Renames a table. | +| [`SHOW COLUMNS FROM`](/sql-statements/sql-statement-show-columns-from.md) | Shows the columns from a table. | +| [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md) | Shows the CREATE statement for a database. | +| [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md) | Shows the CREATE statement for a sequence. | +| [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md) | Shows the CREATE statement for a table. | +| [`SHOW DATABASES`](/sql-statements/sql-statement-show-databases.md) | Shows a list of databases that the current user has privileges to. | +| [`SHOW FIELDS FROM`](/sql-statements/sql-statement-show-fields-from.md) | Shows columns of a table. | +| [`SHOW INDEXES`](/sql-statements/sql-statement-show-indexes.md) | Shows indexes of a table. | +| [`SHOW SCHEMAS`](/sql-statements/sql-statement-show-schemas.md) | An alias to `SHOW DATABASES`, which shows a list of databases that the current user has privileges to. | +| [`SHOW TABLE NEXT_ROW_ID`](/sql-statements/sql-statement-show-table-next-rowid.md) | Shows the next row ID for a table. | +| [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md) | Shows the Region information of a table in TiDB. | +| [`SHOW TABLE STATUS`](/sql-statements/sql-statement-show-table-status.md) | Shows various statistics about tables in TiDB. | +| [`SHOW TABLES`](/sql-statements/sql-statement-show-tables.md) | Shows tables in a database. | +| [`TRUNCATE`](/sql-statements/sql-statement-truncate.md) | Truncates all data from a table. | ## Data manipulation statements (DML) -| SQL Statement | Description | -|---------------|-------------| -| [`BATCH`](/sql-statements/sql-statement-batch.md) | Splits a DML statement into multiple statements in TiDB for execution. | -| [`DELETE`](/sql-statements/sql-statement-delete.md) | Deletes rows from a table. | -| [`INSERT`](/sql-statements/sql-statement-insert.md) | Inserts new rows into a table. | -| [`REPLACE`](/sql-statements/sql-statement-replace.md) | Replaces existing rows or inserts new rows. | -| [`SELECT`](/sql-statements/sql-statement-select.md) | Reads data from a table. | -| [`TABLE`](/sql-statements/sql-statement-table.md) | Retrieves rows from a table. | -| [`UPDATE`](/sql-statements/sql-statement-update.md) | Updates existing rows in a table. | -| [`WITH`](/sql-statements/sql-statement-with.md) | Defines common table expressions. | +| SQL Statement | Description | +| ----------------------------------------------------- | ---------------------------------------------------------------------- | +| [`BATCH`](/sql-statements/sql-statement-batch.md) | Splits a DML statement into multiple statements in TiDB for execution. | +| [`DELETE`](/sql-statements/sql-statement-delete.md) | Deletes rows from a table. | +| [`INSERT`](/sql-statements/sql-statement-insert.md) | Inserts new rows into a table. | +| [`REPLACE`](/sql-statements/sql-statement-replace.md) | Replaces existing rows or inserts new rows. | +| [`SELECT`](/sql-statements/sql-statement-select.md) | Reads data from a table. | +| [`TABLE`](/sql-statements/sql-statement-table.md) | Retrieves rows from a table. | +| [`UPDATE`](/sql-statements/sql-statement-update.md) | Updates existing rows in a table. | +| [`WITH`](/sql-statements/sql-statement-with.md) | Defines common table expressions. | ## Transaction statements -| SQL Statement | Description | -|---------------|-------------| -| [`BEGIN`](/sql-statements/sql-statement-begin.md) | Begins a new transaction. | -| [`COMMIT`](/sql-statements/sql-statement-commit.md) | Commits the current transaction. | -| [`ROLLBACK`](/sql-statements/sql-statement-rollback.md) | Rolls back the current transaction. | -| [`SAVEPOINT`](/sql-statements/sql-statement-savepoint.md) | Sets a savepoint within a transaction. | -| [`SET TRANSACTION`](/sql-statements/sql-statement-set-transaction.md) | Changes the current isolation level on a `GLOBAL` or `SESSION` basis. | -| [`START TRANSACTION`](/sql-statements/sql-statement-start-transaction.md) | Starts a new transaction. | +| SQL Statement | Description | +| ------------------------------------------------------------------------- | --------------------------------------------------------------------- | +| [`BEGIN`](/sql-statements/sql-statement-begin.md) | Begins a new transaction. | +| [`COMMIT`](/sql-statements/sql-statement-commit.md) | Commits the current transaction. | +| [`ROLLBACK`](/sql-statements/sql-statement-rollback.md) | Rolls back the current transaction. | +| [`SAVEPOINT`](/sql-statements/sql-statement-savepoint.md) | Sets a savepoint within a transaction. | +| [`SET TRANSACTION`](/sql-statements/sql-statement-set-transaction.md) | Changes the current isolation level on a `GLOBAL` or `SESSION` basis. | +| [`START TRANSACTION`](/sql-statements/sql-statement-start-transaction.md) | Starts a new transaction. | ## Prepared statements -| SQL Statement | Description | -|---------------|-------------| +| SQL Statement | Description | +| ----------------------------------------------------------- | --------------------------------------------------------------- | | [`DEALLOCATE`](/sql-statements/sql-statement-deallocate.md) | Deallocates a prepared statement, freeing associated resources. | -| [`EXECUTE`](/sql-statements/sql-statement-execute.md) | Executes a prepared statement with specific parameter values. | -| [`PREPARE`](/sql-statements/sql-statement-prepare.md) | Creates a prepared statement with placeholders. | +| [`EXECUTE`](/sql-statements/sql-statement-execute.md) | Executes a prepared statement with specific parameter values. | +| [`PREPARE`](/sql-statements/sql-statement-prepare.md) | Creates a prepared statement with placeholders. | ## Administrative statements -| SQL Statement | Description | -|---------------|-------------| -| [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md) | Modifies the parameter of a single running DDL job. | -| [`ADMIN CANCEL DDL`](/sql-statements/sql-statement-admin-cancel-ddl.md) | Cancels a DDL job. | -| [`ADMIN CHECK [TABLE\|INDEX]`](/sql-statements/sql-statement-admin-check-table-index.md) | Checks the integrity of a table or index. | -| [`ADMIN CHECKSUM TABLE`](/sql-statements/sql-statement-admin-checksum-table.md) | Computes the checksum of a table. | -| [`ADMIN CLEANUP INDEX`](/sql-statements/sql-statement-admin-cleanup.md) | Cleans up indexes from a table. | -| [`ADMIN PAUSE DDL`](/sql-statements/sql-statement-admin-pause-ddl.md) | Pauses DDL operations. | -| [`ADMIN RESUME DDL`](/sql-statements/sql-statement-admin-resume-ddl.md) | Resumes DDL operations. | -| [`ADMIN SHOW DDL [JOBS\|JOB QUERIES]`](/sql-statements/sql-statement-admin-show-ddl.md) | Shows DDL jobs or job queries. | -| [`ADMIN`](/sql-statements/sql-statement-admin.md) | Performs various administrative tasks. | -| [`FLUSH TABLES`](/sql-statements/sql-statement-flush-tables.md) | Included for [MySQL compatibility](/mysql-compatibility.md). It has no effective usage in TiDB. | -| [`SET `](/sql-statements/sql-statement-set-variable.md) | Modifies a system variable or user variable. | -| [`SET [NAMES\|CHARACTER SET]`](/sql-statements/sql-statement-set-names.md) | Set a character set and collation. | -| [`SPLIT REGION`](/sql-statements/sql-statement-split-region.md) | Splits a Region into smaller Regions. | +| SQL Statement | Description | +| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md) | Modifies the parameter of a single running DDL job. | +| [`ADMIN CANCEL DDL`](/sql-statements/sql-statement-admin-cancel-ddl.md) | Cancels a DDL job. | +| [`ADMIN CHECK [TABLE\|INDEX]`](/sql-statements/sql-statement-admin-check-table-index.md) | Checks the integrity of a table or index. | +| [`ADMIN CHECKSUM TABLE`](/sql-statements/sql-statement-admin-checksum-table.md) | Computes the checksum of a table. | +| [`ADMIN CLEANUP INDEX`](/sql-statements/sql-statement-admin-cleanup.md) | Cleans up indexes from a table. | +| [`ADMIN PAUSE DDL`](/sql-statements/sql-statement-admin-pause-ddl.md) | Pauses DDL operations. | +| [`ADMIN RESUME DDL`](/sql-statements/sql-statement-admin-resume-ddl.md) | Resumes DDL operations. | +| [`ADMIN SHOW DDL [JOBS\|JOB QUERIES]`](/sql-statements/sql-statement-admin-show-ddl.md) | Shows DDL jobs or job queries. | +| [`ADMIN`](/sql-statements/sql-statement-admin.md) | Performs various administrative tasks. | +| [`FLUSH TABLES`](/sql-statements/sql-statement-flush-tables.md) | Included for [MySQL compatibility](/mysql-compatibility.md). It has no effective usage in TiDB. | +| [`SET `](/sql-statements/sql-statement-set-variable.md) | Modifies a system variable or user variable. | +| [`SET [NAMES\|CHARACTER SET]`](/sql-statements/sql-statement-set-names.md) | Set a character set and collation. | +| [`SPLIT REGION`](/sql-statements/sql-statement-split-region.md) | Splits a Region into smaller Regions. | -| SQL Statement | Description | -|---------------|-------------| -| [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md) | Modifies the parameter of a single running DDL job. | -| [`ADMIN CANCEL DDL`](/sql-statements/sql-statement-admin-cancel-ddl.md) | Cancels a DDL job. | -| [`ADMIN CHECK [TABLE\|INDEX]`](/sql-statements/sql-statement-admin-check-table-index.md) | Checks the integrity of a table or index. | -| [`ADMIN CHECKSUM TABLE`](/sql-statements/sql-statement-admin-checksum-table.md) | Computes the checksum of a table. | -| [`ADMIN CLEANUP INDEX`](/sql-statements/sql-statement-admin-cleanup.md) | Cleans up indexes from a table. | -| [`ADMIN PAUSE DDL`](/sql-statements/sql-statement-admin-pause-ddl.md) | Pauses DDL operations. | -| [`ADMIN RECOVER INDEX`](/sql-statements/sql-statement-admin-recover.md) | Recovers the consistency based on the redundant indexes. | -| [`ADMIN RESUME DDL`](/sql-statements/sql-statement-admin-resume-ddl.md) | Resumes DDL operations. | -| [`ADMIN SHOW DDL [JOBS\|JOB QUERIES]`](/sql-statements/sql-statement-admin-show-ddl.md) | Shows DDL jobs or job queries. | -| [`ADMIN`](/sql-statements/sql-statement-admin.md) | Performs various administrative tasks. | -| [`FLUSH TABLES`](/sql-statements/sql-statement-flush-tables.md) | Included for [MySQL compatibility](/mysql-compatibility.md). It has no effective usage in TiDB. | -| [`SET `](/sql-statements/sql-statement-set-variable.md) | Modifies a system variable or user variable. | -| [`SET [NAMES\|CHARACTER SET]`](/sql-statements/sql-statement-set-names.md) | Set a character set and collation. | -| [`SPLIT REGION`](/sql-statements/sql-statement-split-region.md) | Splits a Region into smaller Regions. | +| SQL Statement | Description | +| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md) | Modifies the parameter of a single running DDL job. | +| [`ADMIN CANCEL DDL`](/sql-statements/sql-statement-admin-cancel-ddl.md) | Cancels a DDL job. | +| [`ADMIN CHECK [TABLE\|INDEX]`](/sql-statements/sql-statement-admin-check-table-index.md) | Checks the integrity of a table or index. | +| [`ADMIN CHECKSUM TABLE`](/sql-statements/sql-statement-admin-checksum-table.md) | Computes the checksum of a table. | +| [`ADMIN CLEANUP INDEX`](/sql-statements/sql-statement-admin-cleanup.md) | Cleans up indexes from a table. | +| [`ADMIN PAUSE DDL`](/sql-statements/sql-statement-admin-pause-ddl.md) | Pauses DDL operations. | +| [`ADMIN RECOVER INDEX`](/sql-statements/sql-statement-admin-recover.md) | Recovers the consistency based on the redundant indexes. | +| [`ADMIN RESUME DDL`](/sql-statements/sql-statement-admin-resume-ddl.md) | Resumes DDL operations. | +| [`ADMIN SHOW DDL [JOBS\|JOB QUERIES]`](/sql-statements/sql-statement-admin-show-ddl.md) | Shows DDL jobs or job queries. | +| [`ADMIN`](/sql-statements/sql-statement-admin.md) | Performs various administrative tasks. | +| [`FLUSH TABLES`](/sql-statements/sql-statement-flush-tables.md) | Included for [MySQL compatibility](/mysql-compatibility.md). It has no effective usage in TiDB. | +| [`SET `](/sql-statements/sql-statement-set-variable.md) | Modifies a system variable or user variable. | +| [`SET [NAMES\|CHARACTER SET]`](/sql-statements/sql-statement-set-names.md) | Set a character set and collation. | +| [`SPLIT REGION`](/sql-statements/sql-statement-split-region.md) | Splits a Region into smaller Regions. | ## Data import and export -| SQL Statement | Description | -|---------------|-------------| -| [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md) | Cancels an ongoing import job. | -| [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) | Imports data into a table via the [Physical Import Mode](https://docs.pingcap.com/tidb/stable/tidb-lightning-physical-import-mode) of TiDB Lightning. | -| [`LOAD DATA`](/sql-statements/sql-statement-load-data.md) | Loads data into a table from Amazon S3 or Google Cloud Storage. | -| [`SHOW IMPORT JOB`](/sql-statements/sql-statement-show-import-job.md) | Shows the status of an import job. | +| SQL Statement | Description | +| ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md) | Cancels an ongoing import job. | +| [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) | Imports data into a table via the [Physical Import Mode](https://docs.pingcap.com/tidb/stable/tidb-lightning-physical-import-mode) of TiDB Lightning. | +| [`LOAD DATA`](/sql-statements/sql-statement-load-data.md) | Loads data into a table from Amazon S3 or Google Cloud Storage. | +| [`SHOW IMPORT JOB`](/sql-statements/sql-statement-show-import-job.md) | Shows the status of an import job. | ## Backup & restore -| SQL Statement | Description | -|---------------|-------------| -| [`BACKUP`](/sql-statements/sql-statement-backup.md) | Performs a distributed backup of the TiDB cluster. | -| [`FLASHBACK CLUSTER`](/sql-statements/sql-statement-flashback-cluster.md) | Restores the cluster to a specific snapshot. | -| [`FLASHBACK DATABASE`](/sql-statements/sql-statement-flashback-database.md) | Restores a database and its data deleted by the `DROP` statement. | -| [`FLASHBACK TABLE`](/sql-statements/sql-statement-flashback-table.md) | Restore the tables and data dropped by the `DROP` or `TRUNCATE` operation. | -| [`RECOVER TABLE`](/sql-statements/sql-statement-recover-table.md) | Recovers a deleted table and the data on it. | -| [`RESTORE`](/sql-statements/sql-statement-restore.md) | Restores a database from a backup. | -| [`SHOW BACKUPS`](/sql-statements/sql-statement-show-backups.md) | Shows backup tasks. | -| [`SHOW RESTORES`](/sql-statements/sql-statement-show-backups.md) | Shows restore tasks. | +| SQL Statement | Description | +| --------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| [`BACKUP`](/sql-statements/sql-statement-backup.md) | Performs a distributed backup of the TiDB cluster. | +| [`FLASHBACK CLUSTER`](/sql-statements/sql-statement-flashback-cluster.md) | Restores the cluster to a specific snapshot. | +| [`FLASHBACK DATABASE`](/sql-statements/sql-statement-flashback-database.md) | Restores a database and its data deleted by the `DROP` statement. | +| [`FLASHBACK TABLE`](/sql-statements/sql-statement-flashback-table.md) | Restore the tables and data dropped by the `DROP` or `TRUNCATE` operation. | +| [`RECOVER TABLE`](/sql-statements/sql-statement-recover-table.md) | Recovers a deleted table and the data on it. | +| [`RESTORE`](/sql-statements/sql-statement-restore.md) | Restores a database from a backup. | +| [`SHOW BACKUPS`](/sql-statements/sql-statement-show-backups.md) | Shows backup tasks. | +| [`SHOW RESTORES`](/sql-statements/sql-statement-show-backups.md) | Shows restore tasks. | ## Placement policy -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER PLACEMENT POLICY`](/sql-statements/sql-statement-alter-placement-policy.md) | Modifies a placement policy. | -| [`ALTER RANGE`](/sql-statements/sql-statement-alter-range.md) | Modifies the range of a placement policy. | -| [`CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-create-placement-policy.md) | Creates a new placement policy. | -| [`DROP PLACEMENT POLICY`](/sql-statements/sql-statement-drop-placement-policy.md) | Drops an existing placement policy. | +| SQL Statement | Description | +| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------- | +| [`ALTER PLACEMENT POLICY`](/sql-statements/sql-statement-alter-placement-policy.md) | Modifies a placement policy. | +| [`ALTER RANGE`](/sql-statements/sql-statement-alter-range.md) | Modifies the range of a placement policy. | +| [`CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-create-placement-policy.md) | Creates a new placement policy. | +| [`DROP PLACEMENT POLICY`](/sql-statements/sql-statement-drop-placement-policy.md) | Drops an existing placement policy. | | [`SHOW CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-show-create-placement-policy.md) | Shows the `CREATE` statement for a placement policy. | -| [`SHOW PLACEMENT FOR`](/sql-statements/sql-statement-show-placement-for.md) | Shows placement rules for a specific table. | -| [`SHOW PLACEMENT LABELS`](/sql-statements/sql-statement-show-placement-labels.md) | Shows available placement labels. | -| [`SHOW PLACEMENT`](/sql-statements/sql-statement-show-placement.md) | Shows placement rules. | +| [`SHOW PLACEMENT FOR`](/sql-statements/sql-statement-show-placement-for.md) | Shows placement rules for a specific table. | +| [`SHOW PLACEMENT LABELS`](/sql-statements/sql-statement-show-placement-labels.md) | Shows available placement labels. | +| [`SHOW PLACEMENT`](/sql-statements/sql-statement-show-placement.md) | Shows placement rules. | ## Resource groups -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) | Modifies a resource group. | -| [`CALIBRATE RESOURCE`](/sql-statements/sql-statement-calibrate-resource.md) | Estimates and outputs the [Request Unit (RU)](/tidb-resource-control-ru-groups.md#what-is-request-unit-ru) capacity of the current cluster. | -| [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) | Creates a new resource group. | -| [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) | Drops a resource group. | -| [`QUERY WATCH`](/sql-statements/sql-statement-query-watch.md) | Manages the runaway query watch list. | -| [`SET RESOURCE GROUP`](/sql-statements/sql-statement-set-resource-group.md) | Sets a resource group. | -| [`SHOW CREATE RESOURCE GROUP`](/sql-statements/sql-statement-show-create-resource-group.md) | Shows the `CREATE` statement for a resource group. | +| SQL Statement | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | +| [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) | Modifies a resource group. | +| [`CALIBRATE RESOURCE`](/sql-statements/sql-statement-calibrate-resource.md) | Estimates and outputs the [Request Unit (RU)](/tidb-resource-control-ru-groups.md#what-is-request-unit-ru) capacity of the current cluster. | +| [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) | Creates a new resource group. | +| [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) | Drops a resource group. | +| [`QUERY WATCH`](/sql-statements/sql-statement-query-watch.md) | Manages the runaway query watch list. | +| [`SET RESOURCE GROUP`](/sql-statements/sql-statement-set-resource-group.md) | Sets a resource group. | +| [`SHOW CREATE RESOURCE GROUP`](/sql-statements/sql-statement-show-create-resource-group.md) | Shows the `CREATE` statement for a resource group. | -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) | Modifies a resource group. | -| [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) | Creates a new resource group. | -| [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) | Drops a resource group. | -| [`QUERY WATCH`](/sql-statements/sql-statement-query-watch.md) | Manages the runaway query watch list. | -| [`SET RESOURCE GROUP`](/sql-statements/sql-statement-set-resource-group.md) | Sets a resource group. | +| SQL Statement | Description | +| ------------------------------------------------------------------------------------------- | -------------------------------------------------- | +| [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) | Modifies a resource group. | +| [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) | Creates a new resource group. | +| [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) | Drops a resource group. | +| [`QUERY WATCH`](/sql-statements/sql-statement-query-watch.md) | Manages the runaway query watch list. | +| [`SET RESOURCE GROUP`](/sql-statements/sql-statement-set-resource-group.md) | Sets a resource group. | | [`SHOW CREATE RESOURCE GROUP`](/sql-statements/sql-statement-show-create-resource-group.md) | Shows the `CREATE` statement for a resource group. | ## Utility statements -| SQL Statement | Description | -|---------------|-------------| -| [`DESC`](/sql-statements/sql-statement-desc.md) | An alias to `DESCRIBE`, which shows the structure of a table. | -| [`DESCRIBE`](/sql-statements/sql-statement-describe.md) | Shows the structure of a table. | -| [`DO`](/sql-statements/sql-statement-do.md) | Executes an expression but does not return any results. | -| [`EXPLAIN`](/sql-statements/sql-statement-explain.md) | Shows the execution plan of a query. | -| [`TRACE`](/sql-statements/sql-statement-trace.md) | Provides detailed information about query execution. | -| [`USE`](/sql-statements/sql-statement-use.md) | Sets the current database. | +| SQL Statement | Description | +| ------------------------------------------------------- | ------------------------------------------------------------- | +| [`DESC`](/sql-statements/sql-statement-desc.md) | An alias to `DESCRIBE`, which shows the structure of a table. | +| [`DESCRIBE`](/sql-statements/sql-statement-describe.md) | Shows the structure of a table. | +| [`DO`](/sql-statements/sql-statement-do.md) | Executes an expression but does not return any results. | +| [`EXPLAIN`](/sql-statements/sql-statement-explain.md) | Shows the execution plan of a query. | +| [`TRACE`](/sql-statements/sql-statement-trace.md) | Provides detailed information about query execution. | +| [`USE`](/sql-statements/sql-statement-use.md) | Sets the current database. | ## Show statements -| SQL Statement | Description | -|---------------|-------------| -| [`SHOW BUILTINS`](/sql-statements/sql-statement-show-builtins.md) | Lists builtin functions. | -| [`SHOW CHARACTER SET`](/sql-statements/sql-statement-show-character-set.md) | Lists character sets. | -| [`SHOW COLLATIONS`](/sql-statements/sql-statement-show-collation.md) | Lists collations. | -| [`SHOW ERRORS`](/sql-statements/sql-statement-show-errors.md) | Shows errors from previously executed statements. | -| [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB uses [Prometheus and Grafana](/tidb-monitoring-framework.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | -| [`SHOW VARIABLES`](/sql-statements/sql-statement-show-variables.md) | Shows system variables. | -| [`SHOW WARNINGS`](/sql-statements/sql-statement-show-warnings.md) | Shows warnings and notes from previously executed statements. | +| SQL Statement | Description | +| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`SHOW BUILTINS`](/sql-statements/sql-statement-show-builtins.md) | Lists builtin functions. | +| [`SHOW CHARACTER SET`](/sql-statements/sql-statement-show-character-set.md) | Lists character sets. | +| [`SHOW COLLATIONS`](/sql-statements/sql-statement-show-collation.md) | Lists collations. | +| [`SHOW ERRORS`](/sql-statements/sql-statement-show-errors.md) | Shows errors from previously executed statements. | +| [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB uses [Prometheus and Grafana](/tidb-monitoring-framework.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | +| [`SHOW VARIABLES`](/sql-statements/sql-statement-show-variables.md) | Shows system variables. | +| [`SHOW WARNINGS`](/sql-statements/sql-statement-show-warnings.md) | Shows warnings and notes from previously executed statements. | -| SQL Statement | Description | -|---------------|-------------| -| [`SHOW BUILTINS`](/sql-statements/sql-statement-show-builtins.md) | Lists builtin functions. | -| [`SHOW CHARACTER SET`](/sql-statements/sql-statement-show-character-set.md) | Lists character sets. | -| [`SHOW COLLATIONS`](/sql-statements/sql-statement-show-collation.md) | Lists collations. | -| [`SHOW ERRORS`](/sql-statements/sql-statement-show-errors.md) | Shows errors from previously executed statements. | -| [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB Cloud provides [Monitoring](/tidb-cloud/monitor-tidb-cluster.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | -| [`SHOW VARIABLES`](/sql-statements/sql-statement-show-variables.md) | Shows system variables. | -| [`SHOW WARNINGS`](/sql-statements/sql-statement-show-warnings.md) | Shows warnings and notes from previously executed statements. | +| SQL Statement | Description | +| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`SHOW BUILTINS`](/sql-statements/sql-statement-show-builtins.md) | Lists builtin functions. | +| [`SHOW CHARACTER SET`](/sql-statements/sql-statement-show-character-set.md) | Lists character sets. | +| [`SHOW COLLATIONS`](/sql-statements/sql-statement-show-collation.md) | Lists collations. | +| [`SHOW ERRORS`](/sql-statements/sql-statement-show-errors.md) | Shows errors from previously executed statements. | +| [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB Cloud provides [Monitoring](/tidb-cloud/monitor-tidb-cluster.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | +| [`SHOW VARIABLES`](/sql-statements/sql-statement-show-variables.md) | Shows system variables. | +| [`SHOW WARNINGS`](/sql-statements/sql-statement-show-warnings.md) | Shows warnings and notes from previously executed statements. | @@ -232,73 +232,73 @@ TiDB uses SQL statements that aim to follow ISO/IEC SQL standards, with extensio -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER INSTANCE`](/sql-statements/sql-statement-alter-instance.md) | Modifies an instance. | -| [`FLUSH STATUS`](/sql-statements/sql-statement-flush-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB uses [Prometheus and Grafana](/tidb-monitoring-framework.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | -| [`KILL`](/sql-statements/sql-statement-kill.md) | Kills a connection in any TiDB instance in the current TiDB cluster. | -| [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md) | Shows the configuration of various components of TiDB. | -| [`SHOW ENGINES`](/sql-statements/sql-statement-show-engines.md) | Shows available storage engines. | -| [`SHOW PLUGINS`](/sql-statements/sql-statement-show-plugins.md) | Shows installed plugins. | -| [`SHOW PROCESSLIST`](/sql-statements/sql-statement-show-processlist.md) | Shows the current sessions connected to the same TiDB server. | -| [`SHOW PROFILES`](/sql-statements/sql-statement-show-profiles.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). Currently, it only returns an empty result. | -| [`SHUTDOWN`](/sql-statements/sql-statement-shutdown.md) | Stops the client-connected TiDB instance, not the entire TiDB cluster. | +| SQL Statement | Description | +| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`ALTER INSTANCE`](/sql-statements/sql-statement-alter-instance.md) | Modifies an instance. | +| [`FLUSH STATUS`](/sql-statements/sql-statement-flush-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB uses [Prometheus and Grafana](/tidb-monitoring-framework.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | +| [`KILL`](/sql-statements/sql-statement-kill.md) | Kills a connection in any TiDB instance in the current TiDB cluster. | +| [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md) | Shows the configuration of various components of TiDB. | +| [`SHOW ENGINES`](/sql-statements/sql-statement-show-engines.md) | Shows available storage engines. | +| [`SHOW PLUGINS`](/sql-statements/sql-statement-show-plugins.md) | Shows installed plugins. | +| [`SHOW PROCESSLIST`](/sql-statements/sql-statement-show-processlist.md) | Shows the current sessions connected to the same TiDB server. | +| [`SHOW PROFILES`](/sql-statements/sql-statement-show-profiles.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). Currently, it only returns an empty result. | +| [`SHUTDOWN`](/sql-statements/sql-statement-shutdown.md) | Stops the client-connected TiDB instance, not the entire TiDB cluster. | -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER INSTANCE`](/sql-statements/sql-statement-alter-instance.md) | Modifies an instance. | -| [`FLUSH STATUS`](/sql-statements/sql-statement-flush-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB Cloud provides [Monitoring](/tidb-cloud/monitor-tidb-cluster.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | -| [`KILL`](/sql-statements/sql-statement-kill.md) | Kills a connection in any TiDB instance in the current TiDB cluster. | -| [`SHOW ENGINES`](/sql-statements/sql-statement-show-engines.md) | Shows available storage engines. | -| [`SHOW PLUGINS`](/sql-statements/sql-statement-show-plugins.md) | Shows installed plugins. | -| [`SHOW PROCESSLIST`](/sql-statements/sql-statement-show-processlist.md) | Shows the current sessions connected to the same TiDB server. | -| [`SHOW PROFILES`](/sql-statements/sql-statement-show-profiles.md) | Shows query profiles. Included for [compatibility with MySQL](/mysql-compatibility.md). Currently only returns an empty result. | +| SQL Statement | Description | +| ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`ALTER INSTANCE`](/sql-statements/sql-statement-alter-instance.md) | Modifies an instance. | +| [`FLUSH STATUS`](/sql-statements/sql-statement-flush-status.md) | Included for [compatibility with MySQL](/mysql-compatibility.md). TiDB Cloud provides [Monitoring](/tidb-cloud/monitor-tidb-cluster.md) for centralized metrics collection instead of `SHOW STATUS` for most metrics. | +| [`KILL`](/sql-statements/sql-statement-kill.md) | Kills a connection in any TiDB instance in the current TiDB cluster. | +| [`SHOW ENGINES`](/sql-statements/sql-statement-show-engines.md) | Shows available storage engines. | +| [`SHOW PLUGINS`](/sql-statements/sql-statement-show-plugins.md) | Shows installed plugins. | +| [`SHOW PROCESSLIST`](/sql-statements/sql-statement-show-processlist.md) | Shows the current sessions connected to the same TiDB server. | +| [`SHOW PROFILES`](/sql-statements/sql-statement-show-profiles.md) | Shows query profiles. Included for [compatibility with MySQL](/mysql-compatibility.md). Currently only returns an empty result. | ## Locking statements -| SQL Statement | Description | -|---------------|-------------| -| [`LOCK STATS`](/sql-statements/sql-statement-lock-stats.md) | Locks statistics of tables or partitions. | -| [`LOCK TABLES`](/sql-statements/sql-statement-lock-tables-and-unlock-tables.md) | Locks tables for the current session. | -| [`UNLOCK STATS`](/sql-statements/sql-statement-unlock-stats.md) | Unlocks statistics of tables or partitions. | -| [`UNLOCK TABLES`](/sql-statements/sql-statement-lock-tables-and-unlock-tables.md) | Unlocks tables. | +| SQL Statement | Description | +| --------------------------------------------------------------------------------- | ------------------------------------------- | +| [`LOCK STATS`](/sql-statements/sql-statement-lock-stats.md) | Locks statistics of tables or partitions. | +| [`LOCK TABLES`](/sql-statements/sql-statement-lock-tables-and-unlock-tables.md) | Locks tables for the current session. | +| [`UNLOCK STATS`](/sql-statements/sql-statement-unlock-stats.md) | Unlocks statistics of tables or partitions. | +| [`UNLOCK TABLES`](/sql-statements/sql-statement-lock-tables-and-unlock-tables.md) | Unlocks tables. | ## Account management / Data Control Language -| SQL Statement | Description | -|---------------|-------------| -| [`ALTER USER`](/sql-statements/sql-statement-alter-user.md) | Modifies a user. | -| [`CREATE ROLE`](/sql-statements/sql-statement-create-role.md) | Creates a role. | -| [`CREATE USER`](/sql-statements/sql-statement-create-user.md) | Creates a new user. | -| [`DROP ROLE`](/sql-statements/sql-statement-drop-role.md) | Drops an existing role. | -| [`DROP USER`](/sql-statements/sql-statement-drop-user.md) | Drops an existing user. | -| [`FLUSH PRIVILEGES`](/sql-statements/sql-statement-flush-privileges.md) | Reloads the in-memory copy of privileges from the privilege tables. | -| [`GRANT `](/sql-statements/sql-statement-grant-privileges.md) | Grants privileges. | -| [`GRANT `](/sql-statements/sql-statement-grant-role.md) | Grants a role. | -| [`RENAME USER`](/sql-statements/sql-statement-rename-user.md) | Renames an existing user. | -| [`REVOKE `](/sql-statements/sql-statement-revoke-privileges.md) | Revokes privileges. | -| [`REVOKE `](/sql-statements/sql-statement-revoke-role.md) | Revokes a role. | -| [`SET DEFAULT ROLE`](/sql-statements/sql-statement-set-default-role.md) | Sets a default role. | -| [`SET PASSWORD`](/sql-statements/sql-statement-set-password.md) | Changes a password. | -| [`SET ROLE`](/sql-statements/sql-statement-set-role.md) | Enables roles in the current session. | -| [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md) | Shows the `CREATE` statement for a user. | -| [`SHOW GRANTS`](/sql-statements/sql-statement-show-grants.md) | Shows privileges associated with a user. | -| [`SHOW PRIVILEGES`](/sql-statements/sql-statement-show-privileges.md) | Shows available privileges. | +| SQL Statement | Description | +| --------------------------------------------------------------------------- | ------------------------------------------------------------------- | +| [`ALTER USER`](/sql-statements/sql-statement-alter-user.md) | Modifies a user. | +| [`CREATE ROLE`](/sql-statements/sql-statement-create-role.md) | Creates a role. | +| [`CREATE USER`](/sql-statements/sql-statement-create-user.md) | Creates a new user. | +| [`DROP ROLE`](/sql-statements/sql-statement-drop-role.md) | Drops an existing role. | +| [`DROP USER`](/sql-statements/sql-statement-drop-user.md) | Drops an existing user. | +| [`FLUSH PRIVILEGES`](/sql-statements/sql-statement-flush-privileges.md) | Reloads the in-memory copy of privileges from the privilege tables. | +| [`GRANT `](/sql-statements/sql-statement-grant-privileges.md) | Grants privileges. | +| [`GRANT `](/sql-statements/sql-statement-grant-role.md) | Grants a role. | +| [`RENAME USER`](/sql-statements/sql-statement-rename-user.md) | Renames an existing user. | +| [`REVOKE `](/sql-statements/sql-statement-revoke-privileges.md) | Revokes privileges. | +| [`REVOKE `](/sql-statements/sql-statement-revoke-role.md) | Revokes a role. | +| [`SET DEFAULT ROLE`](/sql-statements/sql-statement-set-default-role.md) | Sets a default role. | +| [`SET PASSWORD`](/sql-statements/sql-statement-set-password.md) | Changes a password. | +| [`SET ROLE`](/sql-statements/sql-statement-set-role.md) | Enables roles in the current session. | +| [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md) | Shows the `CREATE` statement for a user. | +| [`SHOW GRANTS`](/sql-statements/sql-statement-show-grants.md) | Shows privileges associated with a user. | +| [`SHOW PRIVILEGES`](/sql-statements/sql-statement-show-privileges.md) | Shows available privileges. | ## TiCDC -| SQL Statement | Description | -|---------------|-------------| -| [`ADMIN [SET\|SHOW\|UNSET] BDR ROLE`](/sql-statements/sql-statement-admin-bdr-role.md) | Manages BDR roles. | -| [`SHOW MASTER STATUS`](/sql-statements/sql-statement-show-master-status.md) | Shows the latest TSO in the cluster. | +| SQL Statement | Description | +| -------------------------------------------------------------------------------------- | ------------------------------------ | +| [`ADMIN [SET\|SHOW\|UNSET] BDR ROLE`](/sql-statements/sql-statement-admin-bdr-role.md) | Manages BDR roles. | +| [`SHOW MASTER STATUS`](/sql-statements/sql-statement-show-master-status.md) | Shows the latest TSO in the cluster. | @@ -306,30 +306,31 @@ TiDB uses SQL statements that aim to follow ISO/IEC SQL standards, with extensio > **Note:** > -> [TiCDC](https://docs.pingcap.com/tidb/stable/ticdc-overview) & [TiDB Binlog](https://docs.pingcap.com/tidb/v8.3/tidb-binlog-overview) are tools for replicating TiDB data to the upstream for TiDB Self-Managed. Most SQL statements for TiCDC and TiDB Binlog are not applicable to TiDB Cloud. For TiDB Cloud, you can use the [Changefeed](/tidb-cloud/changefeed-overview.md) feature in the [TiDB Cloud console](https://tidbcloud.com) instead to stream data. +> [TiCDC](https://docs.pingcap.com/tidb/stable/ticdc-overview) & [TiDB Binlog](https://docs-archive.pingcap.com/tidb/v8.3/tidb-binlog-overview) are tools for replicating TiDB data to the upstream for TiDB Self-Managed. Most SQL statements for TiCDC and TiDB Binlog are not applicable to TiDB Cloud. For TiDB Cloud, you can use the [Changefeed](/tidb-cloud/changefeed-overview.md) feature in the [TiDB Cloud console](https://tidbcloud.com) instead to stream data. -| SQL Statement | Description | -|---------------|-------------| +| SQL Statement | Description | +| --------------------------------------------------------------------------- | ------------------------------------ | | [`SHOW MASTER STATUS`](/sql-statements/sql-statement-show-master-status.md) | Shows the latest TSO in the cluster. | ## Statistics and plan management -| SQL Statement | Description | -|---------------|-------------| -| [`ANALYZE TABLE`](/sql-statements/sql-statement-analyze-table.md) | Collects statistics about a table. | -| [`CREATE BINDING`](/sql-statements/sql-statement-create-binding.md) | Creates an execution plan binding for a SQL statement. | -| [`DROP BINDING`](/sql-statements/sql-statement-drop-binding.md) | Drops an execution plan binding from a SQL statement. | -| [`DROP STATS`](/sql-statements/sql-statement-drop-stats.md) | Drops statistics from a table. | -| [`EXPLAIN ANALYZE`](/sql-statements/sql-statement-explain-analyze.md) | Works similar to `EXPLAIN`, with the major difference that it will execute the statement. | -| [`LOAD STATS`](/sql-statements/sql-statement-load-stats.md) | Loads statistics into TiDB. | -| [`SHOW ANALYZE STATUS`](/sql-statements/sql-statement-show-analyze-status.md) | Shows statistics collection tasks. | -| [`SHOW BINDINGS`](/sql-statements/sql-statement-show-bindings.md) | Shows created SQL bindings. | -| [`SHOW COLUMN_STATS_USAGE`](/sql-statements/sql-statement-show-column-stats-usage.md) | Shows the last usage time and collection time of column statistics. | -| [`SHOW STATS_BUCKETS`](/sql-statements/sql-statement-show-stats-buckets.md) | Shows the bucket information in statistics. | -| [`SHOW STATS_HEALTHY`](/sql-statements/sql-statement-show-stats-healthy.md) | Shows an estimation of how accurate statistics are believed to be. | -| [`SHOW STATS_HISTOGRAMS`](/sql-statements/sql-statement-show-stats-histograms.md) | Shows the histogram information in statistics. | -| [`SHOW STATS_LOCKED`](/sql-statements/sql-statement-show-stats-locked.md) | Shows the tables whose statistics are locked. | -| [`SHOW STATS_META`](/sql-statements/sql-statement-show-stats-meta.md) | Shows how many rows are in a table and how many rows are changed in that table. | -| [`SHOW STATS_TOPN`](/sql-statements/sql-statement-show-stats-topn.md) | Shows the Top-N information in statistics. | +| SQL Statement | Description | +| ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| [`ANALYZE TABLE`](/sql-statements/sql-statement-analyze-table.md) | Collects statistics about a table. | +| [`CREATE BINDING`](/sql-statements/sql-statement-create-binding.md) | Creates an execution plan binding for a SQL statement. | +| [`DROP BINDING`](/sql-statements/sql-statement-drop-binding.md) | Drops an execution plan binding from a SQL statement. | +| [`DROP STATS`](/sql-statements/sql-statement-drop-stats.md) | Drops statistics from a table. | +| [`EXPLAIN ANALYZE`](/sql-statements/sql-statement-explain-analyze.md) | Works similar to `EXPLAIN`, with the major difference that it will execute the statement. | +| [`LOAD STATS`](/sql-statements/sql-statement-load-stats.md) | Loads statistics into TiDB. | +| [`REFRESH STATS`](/sql-statements/sql-statement-refresh-stats.md) | Reloads persisted statistics into memory for specific tables or the entire cluster. | +| [`SHOW ANALYZE STATUS`](/sql-statements/sql-statement-show-analyze-status.md) | Shows statistics collection tasks. | +| [`SHOW BINDINGS`](/sql-statements/sql-statement-show-bindings.md) | Shows created SQL bindings. | +| [`SHOW COLUMN_STATS_USAGE`](/sql-statements/sql-statement-show-column-stats-usage.md) | Shows the last usage time and collection time of column statistics. | +| [`SHOW STATS_BUCKETS`](/sql-statements/sql-statement-show-stats-buckets.md) | Shows the bucket information in statistics. | +| [`SHOW STATS_HEALTHY`](/sql-statements/sql-statement-show-stats-healthy.md) | Shows an estimation of how accurate statistics are believed to be. | +| [`SHOW STATS_HISTOGRAMS`](/sql-statements/sql-statement-show-stats-histograms.md) | Shows the histogram information in statistics. | +| [`SHOW STATS_LOCKED`](/sql-statements/sql-statement-show-stats-locked.md) | Shows the tables whose statistics are locked. | +| [`SHOW STATS_META`](/sql-statements/sql-statement-show-stats-meta.md) | Shows how many rows are in a table and how many rows are changed in that table. | +| [`SHOW STATS_TOPN`](/sql-statements/sql-statement-show-stats-topn.md) | Shows the Top-N information in statistics. | diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md new file mode 100644 index 0000000000000..cccda32d9563a --- /dev/null +++ b/sql-statements/sql-statement-refresh-stats.md @@ -0,0 +1,98 @@ +--- +title: REFRESH STATS +summary: Learn how to reload statistics into memory for specific tables or the whole TiDB cluster. +aliases: ['/docs/dev/sql-statements/sql-statement-refresh-stats/'] +--- + +# REFRESH STATS + +`REFRESH STATS` reloads persisted optimizer statistics from the TiDB system tables into memory. This statement is primarily intended for scenarios where statistics have been restored externally (for example, by BR) or when you need to reconcile in-memory statistics without rerunning `ANALYZE`. + +When you run `REFRESH STATS`, TiDB reuses the statistics initialization routines that are automatically triggered at startup. You can reload statistics for individual tables, every table in selected databases, or the entire cluster, and optionally choose whether to perform lightweight (`LITE`) or full (`FULL`) initialization. + +> **Warning:** +> +> This statement exists primarily for BR workflows that must reload statistics after a physical restore. Outside of BR, only run it when you explicitly debug in-memory statistics, and do not execute it on production clusters during ordinary operations. + +## Synopsis + +```ebnf+diagram +RefreshStatsStmt ::= + 'REFRESH' 'STATS' RefreshTargetList RefreshMode? ClusterOption? + +RefreshTargetList ::= + RefreshTarget (',' RefreshTarget)* + +RefreshTarget ::= + TableName + | SchemaWildcard + | GlobalWildcard + +TableName ::= + Identifier ('.' Identifier)? + +SchemaWildcard ::= + Identifier '.' '*' + +GlobalWildcard ::= + '*' '.' '*' + +RefreshMode ::= + 'FULL' + | 'LITE' + +ClusterOption ::= + 'CLUSTER' +``` + +## Options + +- **Targets (`RefreshTargetList`)** + - `table_name` refreshes a table in the current database. + - `db_name.table_name` refreshes a fully qualified table. + - `db_name.*` refreshes every table in the specified database. + - `*.*` refreshes every table in the cluster. +- **`FULL`** Forces TiDB to load full statistics (histograms, TopN, CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately after the refresh. +- **`LITE`** Uses lightweight initialization, equivalent to `lite-init-stats = true`, which skips loading histograms and other heavy structures until they are needed. +- **`CLUSTER`** Broadcasts the refresh request to every TiDB server. Without this keyword, only the TiDB node that receives the statement reloads its in-memory statistics. +- **Default mode** If neither `FULL` nor `LITE` is specified, TiDB uses the current value of [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710). + +## Examples + +- Refresh statistics for a single table on the connected TiDB node: + + {{< copyable "sql" >}} + + ```sql + REFRESH STATS orders; + ``` + +- Refresh all tables in `sales` with lightweight initialization: + + {{< copyable "sql" >}} + + ```sql + REFRESH STATS sales.* LITE; + ``` + +- Force every TiDB node to load full statistics for the entire cluster: + + {{< copyable "sql" >}} + + ```sql + REFRESH STATS *.* FULL CLUSTER; + ``` + +## Privileges + +To execute `REFRESH STATS`, you must either have the `RESTORE_ADMIN` privilege or hold `SELECT` on every targeted table. If you do not have sufficient privileges, TiDB returns an error and aborts the statement. + +## MySQL compatibility + +`REFRESH STATS` is a TiDB-specific extension and is not part of MySQL. + +## See also + +- [Statistics](/statistics.md) +- [`ANALYZE TABLE`](/sql-statements/sql-statement-analyze-table.md) +- [`LOCK STATS`](/sql-statements/sql-statement-lock-stats.md) From 0c1413018660b4f1d9a54185a11f90f21c3a356d Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Wed, 15 Oct 2025 09:10:56 +0200 Subject: [PATCH 02/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index cccda32d9563a..4950cadb68399 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -1,7 +1,6 @@ --- title: REFRESH STATS summary: Learn how to reload statistics into memory for specific tables or the whole TiDB cluster. -aliases: ['/docs/dev/sql-statements/sql-statement-refresh-stats/'] --- # REFRESH STATS From 2f8a91c615810bc51ed7ebafcd757765472d8e6a Mon Sep 17 00:00:00 2001 From: 0xPoe Date: Wed, 15 Oct 2025 09:14:45 +0200 Subject: [PATCH 03/17] fix: update --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 4950cadb68399..3464dee61fc2e 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -11,7 +11,7 @@ When you run `REFRESH STATS`, TiDB reuses the statistics initialization routines > **Warning:** > -> This statement exists primarily for BR workflows that must reload statistics after a physical restore. Outside of BR, only run it when you explicitly debug in-memory statistics, and do not execute it on production clusters during ordinary operations. +> This statement is built for BR's internal restore workflow and BR runs it automatically when needed. Do not execute it manually unless you are debugging in-memory statistics, and never run it on production clusters as part of routine operations. ## Synopsis From 1e762123960d75d70c328db1e8345ef0ec40fa76 Mon Sep 17 00:00:00 2001 From: 0xPoe Date: Mon, 3 Nov 2025 10:02:21 +0100 Subject: [PATCH 04/17] fix: do not run concurrently --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 3464dee61fc2e..233dd68bf98f4 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -11,7 +11,7 @@ When you run `REFRESH STATS`, TiDB reuses the statistics initialization routines > **Warning:** > -> This statement is built for BR's internal restore workflow and BR runs it automatically when needed. Do not execute it manually unless you are debugging in-memory statistics, and never run it on production clusters as part of routine operations. +> This statement is built for BR's internal restore workflow and BR runs it automatically when needed. Do not execute it manually unless you are debugging in-memory statistics, and never run it on production clusters as part of routine operations. Additionally, do not run this statement concurrently for the same tables, as it may lead to unexpected behavior. ## Synopsis From 393f485d6d2599da9b52fd50a6fc99c2df4ef3ce Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Wed, 19 Nov 2025 15:56:39 +0800 Subject: [PATCH 05/17] remove the copyable code snippet since the docs site already has a built-in copy button --- sql-statements/sql-statement-refresh-stats.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 233dd68bf98f4..32ec3e99ececf 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -60,24 +60,18 @@ ClusterOption ::= - Refresh statistics for a single table on the connected TiDB node: - {{< copyable "sql" >}} - ```sql REFRESH STATS orders; ``` - Refresh all tables in `sales` with lightweight initialization: - {{< copyable "sql" >}} - ```sql REFRESH STATS sales.* LITE; ``` - Force every TiDB node to load full statistics for the entire cluster: - {{< copyable "sql" >}} - ```sql REFRESH STATS *.* FULL CLUSTER; ``` From 282ca135f37d677af257a0a4262d69f95945a703 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:51:43 +0200 Subject: [PATCH 06/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 32ec3e99ececf..bea7e0503bbbd 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -5,7 +5,7 @@ summary: Learn how to reload statistics into memory for specific tables or the w # REFRESH STATS -`REFRESH STATS` reloads persisted optimizer statistics from the TiDB system tables into memory. This statement is primarily intended for scenarios where statistics have been restored externally (for example, by BR) or when you need to reconcile in-memory statistics without rerunning `ANALYZE`. +`REFRESH STATS` reloads persisted optimizer statistics from the TiDB system tables into memory. This statement is primarily intended for scenarios where statistics have been restored externally (for example, by [BR](/br/br-use-overview.md)) or when you need to reconcile in-memory statistics without rerunning `ANALYZE`. When you run `REFRESH STATS`, TiDB reuses the statistics initialization routines that are automatically triggered at startup. You can reload statistics for individual tables, every table in selected databases, or the entire cluster, and optionally choose whether to perform lightweight (`LITE`) or full (`FULL`) initialization. From 73c14f14403ed05c8b212eda4841e2c8f53abb63 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:51:53 +0200 Subject: [PATCH 07/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index bea7e0503bbbd..8ac38728bd5d7 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -11,7 +11,10 @@ When you run `REFRESH STATS`, TiDB reuses the statistics initialization routines > **Warning:** > -> This statement is built for BR's internal restore workflow and BR runs it automatically when needed. Do not execute it manually unless you are debugging in-memory statistics, and never run it on production clusters as part of routine operations. Additionally, do not run this statement concurrently for the same tables, as it may lead to unexpected behavior. +> This statement is designed for the internal restore workflow of BR, and BR runs it automatically when needed. +> +> - **DO NOT** execute this statement manually unless you are debugging in-memory statistics, and never run it on production clusters as part of routine operations. +> - **DO NOT** execute this statement concurrently on the same tables, as it might lead to unexpected behavior. ## Synopsis From 75211e8a2f0e6202f22117a060bfe32865b193a3 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:52:03 +0200 Subject: [PATCH 08/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 8ac38728bd5d7..1d394272f7b4c 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -81,7 +81,7 @@ ClusterOption ::= ## Privileges -To execute `REFRESH STATS`, you must either have the `RESTORE_ADMIN` privilege or hold `SELECT` on every targeted table. If you do not have sufficient privileges, TiDB returns an error and aborts the statement. +To execute `REFRESH STATS`, you must either have the `RESTORE_ADMIN` privilege or have the `SELECT` privilege on every target table. If your privileges are insufficient, TiDB returns an error and aborts the statement execution. ## MySQL compatibility From 2992bbb0289c28f599428730e7ab9745fd0e8189 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:52:13 +0200 Subject: [PATCH 09/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 1d394272f7b4c..a07ad8c52f7f3 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -57,7 +57,7 @@ ClusterOption ::= - **`FULL`** Forces TiDB to load full statistics (histograms, TopN, CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately after the refresh. - **`LITE`** Uses lightweight initialization, equivalent to `lite-init-stats = true`, which skips loading histograms and other heavy structures until they are needed. - **`CLUSTER`** Broadcasts the refresh request to every TiDB server. Without this keyword, only the TiDB node that receives the statement reloads its in-memory statistics. -- **Default mode** If neither `FULL` nor `LITE` is specified, TiDB uses the current value of [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710). +- **Default mode**: If neither `FULL` nor `LITE` is specified, TiDB uses the current value of [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710). ## Examples From a331342c032e3499b4bd1146027d177124c64e13 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:52:21 +0200 Subject: [PATCH 10/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index a07ad8c52f7f3..a97bcf3799bd4 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -73,7 +73,7 @@ ClusterOption ::= REFRESH STATS sales.* LITE; ``` -- Force every TiDB node to load full statistics for the entire cluster: +- Force every TiDB node to load complete statistics for the entire cluster: ```sql REFRESH STATS *.* FULL CLUSTER; From a377ea29f9b3aae4efc0d91cb9b76bf6d7637f2f Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:52:31 +0200 Subject: [PATCH 11/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index a97bcf3799bd4..bcadf9a8ee793 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -54,9 +54,9 @@ ClusterOption ::= - `db_name.table_name` refreshes a fully qualified table. - `db_name.*` refreshes every table in the specified database. - `*.*` refreshes every table in the cluster. -- **`FULL`** Forces TiDB to load full statistics (histograms, TopN, CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately after the refresh. -- **`LITE`** Uses lightweight initialization, equivalent to `lite-init-stats = true`, which skips loading histograms and other heavy structures until they are needed. -- **`CLUSTER`** Broadcasts the refresh request to every TiDB server. Without this keyword, only the TiDB node that receives the statement reloads its in-memory statistics. +- **`FULL`**: loads complete statistics (such as histograms, TopN, and CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately. +- **`LITE`**: performs lightweight initialization, equivalent to `lite-init-stats = true`, which skips loading histograms and other heavy structures until they are needed. +- **`CLUSTER`**: broadcasts the refresh request to every TiDB server. Without this option, only the TiDB node that receives the statement reloads its in-memory statistics. - **Default mode**: If neither `FULL` nor `LITE` is specified, TiDB uses the current value of [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710). ## Examples From 8f7220e975b2396fee72a89d53b5761572b1ecac Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Tue, 28 Apr 2026 10:52:42 +0200 Subject: [PATCH 12/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index bcadf9a8ee793..392384a8b0afd 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -49,7 +49,7 @@ ClusterOption ::= ## Options -- **Targets (`RefreshTargetList`)** +- **Targets (`RefreshTargetList`)**: - `table_name` refreshes a table in the current database. - `db_name.table_name` refreshes a fully qualified table. - `db_name.*` refreshes every table in the specified database. From 32617a2c2524430b83a12668eb55667771a123b9 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Wed, 6 May 2026 12:16:09 +0200 Subject: [PATCH 13/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Grace Cai --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 392384a8b0afd..ca18ee2067f8c 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -51,7 +51,7 @@ ClusterOption ::= - **Targets (`RefreshTargetList`)**: - `table_name` refreshes a table in the current database. - - `db_name.table_name` refreshes a fully qualified table. + - `db_name.table_name` refreshes a table in the specified database. - `db_name.*` refreshes every table in the specified database. - `*.*` refreshes every table in the cluster. - **`FULL`**: loads complete statistics (such as histograms, TopN, and CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately. From 8a2bbfe9a1bed785ef6fda604d493440d113518e Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Wed, 20 May 2026 11:07:39 +0200 Subject: [PATCH 14/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Aolin --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index ca18ee2067f8c..944fa9a60a974 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -85,7 +85,7 @@ To execute `REFRESH STATS`, you must either have the `RESTORE_ADMIN` privilege o ## MySQL compatibility -`REFRESH STATS` is a TiDB-specific extension and is not part of MySQL. +`REFRESH STATS` is a TiDB extension to MySQL syntax. ## See also From 1150c95b3cb621a4eb5bb5925840b55750e0d8f7 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Wed, 20 May 2026 11:07:50 +0200 Subject: [PATCH 15/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Aolin --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 944fa9a60a974..e26a34c694124 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -81,7 +81,7 @@ ClusterOption ::= ## Privileges -To execute `REFRESH STATS`, you must either have the `RESTORE_ADMIN` privilege or have the `SELECT` privilege on every target table. If your privileges are insufficient, TiDB returns an error and aborts the statement execution. +To execute `REFRESH STATS`, you must have either the `RESTORE_ADMIN` privilege or the `SELECT` privilege on every target table. If your privileges are insufficient, TiDB returns an error and aborts the statement. ## MySQL compatibility From a514a60b8a39217f9379dd312315130266527ff4 Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Wed, 20 May 2026 11:07:59 +0200 Subject: [PATCH 16/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Aolin --- sql-statements/sql-statement-refresh-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index e26a34c694124..49d60765694a0 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -57,7 +57,7 @@ ClusterOption ::= - **`FULL`**: loads complete statistics (such as histograms, TopN, and CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately. - **`LITE`**: performs lightweight initialization, equivalent to `lite-init-stats = true`, which skips loading histograms and other heavy structures until they are needed. - **`CLUSTER`**: broadcasts the refresh request to every TiDB server. Without this option, only the TiDB node that receives the statement reloads its in-memory statistics. -- **Default mode**: If neither `FULL` nor `LITE` is specified, TiDB uses the current value of [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710). +- **Default mode**: if neither `FULL` nor `LITE` is specified, TiDB uses the value of [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710). ## Examples From bd0d7a0d8657b1a272fba5722b9d0cebcdc0d81f Mon Sep 17 00:00:00 2001 From: Dongpo Liu Date: Wed, 20 May 2026 11:08:19 +0200 Subject: [PATCH 17/17] Update sql-statements/sql-statement-refresh-stats.md Co-authored-by: Aolin --- sql-statements/sql-statement-refresh-stats.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql-statements/sql-statement-refresh-stats.md b/sql-statements/sql-statement-refresh-stats.md index 49d60765694a0..7046006d905f1 100644 --- a/sql-statements/sql-statement-refresh-stats.md +++ b/sql-statements/sql-statement-refresh-stats.md @@ -50,10 +50,10 @@ ClusterOption ::= ## Options - **Targets (`RefreshTargetList`)**: - - `table_name` refreshes a table in the current database. - - `db_name.table_name` refreshes a table in the specified database. - - `db_name.*` refreshes every table in the specified database. - - `*.*` refreshes every table in the cluster. + - `table_name`: refreshes a table in the current database. + - `db_name.table_name`: refreshes a table in the specified database. + - `db_name.*`: refreshes every table in the specified database. + - `*.*`: refreshes every table in the cluster. - **`FULL`**: loads complete statistics (such as histograms, TopN, and CMSketches) into memory, equivalent to setting [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) to `false` for this operation. Use this when you need complete statistics immediately. - **`LITE`**: performs lightweight initialization, equivalent to `lite-init-stats = true`, which skips loading histograms and other heavy structures until they are needed. - **`CLUSTER`**: broadcasts the refresh request to every TiDB server. Without this option, only the TiDB node that receives the statement reloads its in-memory statistics.