diff --git a/TOC.md b/TOC.md index e55f3908149cb..94a16172d8988 100644 --- a/TOC.md +++ b/TOC.md @@ -231,6 +231,7 @@ + [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md) + [`DROP INDEX`](/sql-statements/sql-statement-drop-index.md) + [`DROP SEQUENCE`](/sql-statements/sql-statement-drop-sequence.md) + - [`DROP STATS`](/sql-statements/sql-statement-drop-stats.md) + [`DROP TABLE`](/sql-statements/sql-statement-drop-table.md) + [`DROP USER`](/sql-statements/sql-statement-drop-user.md) + [`DROP VIEW`](/sql-statements/sql-statement-drop-view.md) diff --git a/sql-statements/sql-statement-drop-stats.md b/sql-statements/sql-statement-drop-stats.md new file mode 100644 index 0000000000000..5fe1ee64fe25a --- /dev/null +++ b/sql-statements/sql-statement-drop-stats.md @@ -0,0 +1,70 @@ +--- +title: DROP STATS +summary: An overview of the usage of DROP STATS for the TiDB database. +category: reference +--- + +# DROP STATS + +The `DROP STATS` statement is used to delete the statistics of the selected table from the selected database. + +## Synopsis + +**DropStatsStmt:** + +![DropTableStmt](/media/sqlgram/DropStatsStmt.png) + +**TableName:** + +![TableName](/media/sqlgram/TableName.png) + +## Examples + +{{< copyable "sql" >}} + +```sql +CREATE TABLE t(a INT); +``` + +```sql +Query OK, 0 rows affected (0.01 sec) +``` + +{{< copyable "sql" >}} + +```sql +SHOW STATS_META WHERE db_name='test' and table_name='t'; +``` + +```sql ++---------+------------+----------------+---------------------+--------------+-----------+ +| Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count | ++---------+------------+----------------+---------------------+--------------+-----------+ +| test | t | | 2020-05-25 20:34:33 | 0 | 0 | ++---------+------------+----------------+---------------------+--------------+-----------+ +1 row in set (0.00 sec) +``` + +{{< copyable "sql" >}} + +```sql +DROP STATS t; +``` + +```sql +Query OK, 0 rows affected (0.00 sec) +``` + +{{< copyable "sql" >}} + +```sql +SHOW STATS_META WHERE db_name='test' and table_name='t'; +``` + +```sql +Empty set (0.00 sec) +``` + +## See also + +* [Introduction to Statistics](/statistics.md) diff --git a/statistics.md b/statistics.md index 1f137e7eb61ed..ff4f2a07965b6 100644 --- a/statistics.md +++ b/statistics.md @@ -313,3 +313,7 @@ LOAD STATS 'file_name' ``` `file_name` is the file name of the statistics to be imported. + +## See also + +* [DROP STATS](/sql-statements/sql-statement-drop-stats.md) \ No newline at end of file