Removes statistics from the sysstatistics system table.
delete [shared] statistics table_name [partition data_partition_name] [(column_name[, column_name] ...)]
removes simulated statistics information from sysstatistics in the master database.
removes statistics for all columns in the table.
deletes all statistics for the data partition. Global statistics are not deleted.
removes statistics for the specified column.
Deletes the densities, selectivities, and histograms for all columns in the titles table:
delete statistics titles
Deletes densities, selectivities, and histograms for the pub_id column in the titles table:
delete statistics titles (pub_id)
Deletes densities, selectivities, and histograms for the smallsales partition of the titles table:
delete statistics titles partition smallsales
Deletes densities, selectivities, and histograms for pub_id, pubdate, without affecting statistics on the single-column pub_id or the single-column pubdate:
delete statistics titles (pub_id, pubdate)
Deletes densities, selectivities, and histograms for the column pub_id and for the data partition smallsales:
delete statistics titles partition smallsales (pub_id)
delete statistics does not affect statistics in the systabstats table.
delete statistics on a data partition does not delete global statistics.
When you issue the drop table command, the corresponding rows in sysstatistics are dropped. When you use drop index, the rows in sysstatistics are not deleted. This allows the query optimizer to continue to use index statistics without incurring the overhead of maintaining the index on the table.
WARNING! Densities, selectivities, and histograms are essential to good query optimization. The delete statistics command is provided as a tool to remove statistics not used by the optimizer. If you inadvertently delete statistics needed for query optimization, run update statistics on the table, index, or column.
Loading simulated statistics with the optdiag utility command adds a small number of rows to master..sysstatistics table. If the simulated statistics are no longer in use, use the delete shared statistic command to drop the information in master..sysstatistics.
ANSI SQL – Compliance level: Transact-SQL extension.
The permission checks for delete statistics differ based on your granular permissions settings.
Granular permissions enabled |
With granular permissions enabled, you must be the table owner, or a user with delete statistics permission. |
Granular permissions disabled |
With granular permissions disabled, you must be the table owner, a user with sa_role, or a user with delete statistics permission.. delete statistics permission an be granted or transferred to anyone by table owner or system administrator. |
Commands create index, grant, revoke, update