DROP STATISTICS (Transact-SQL)

Berlaku untuk:SQL ServerAzure SQL DatabaseAzure SQL Managed InstanceAzure Synapse Analytics AnalyticsPlatform System (PDW)Titik akhir analitik SQL di Microsoft FabricWarehouse di Microsoft Fabric

Menghilangkan statistik untuk beberapa koleksi dalam tabel yang ditentukan dalam database saat ini.

Catatan

Untuk informasi selengkapnya tentang statistik di Microsoft Fabric, lihat Statistik di Microsoft Fabric.

Konvensi sintaks transact-SQL

Sintaksis

-- Syntax for SQL Server and Azure SQL Database  
  
DROP STATISTICS table.statistics_name | view.statistics_name [ ,...n ]  
-- Syntax for Azure Synapse Analytics and Parallel Data Warehouse and Microsoft Fabric
  
DROP STATISTICS [ schema_name . ] table_name.statistics_name   
[;]  

Catatan

Untuk melihat sintaks Transact-SQL untuk SQL Server 2014 (12.x) dan versi yang lebih lama, lihat Dokumentasi versi sebelumnya.

Argumen

tampilan tabel |
Adalah nama tabel target atau tampilan terindeks yang statistiknya harus dihilangkan. Nama tabel dan tampilan harus mematuhi aturan untuk Pengidentifikasi Database. Menentukan nama pemilik tabel atau tampilan bersifat opsional.

statistics_name
Adalah nama grup statistik yang akan dihilangkan. Nama statistik harus mematuhi aturan untuk pengidentifikasi

Keterangan

Berhati-hatilah saat Anda menghilangkan statistik. Melakukannya dapat memengaruhi rencana eksekusi yang dipilih oleh pengoptimal kueri.

Statistik pada indeks tidak dapat dihilangkan dengan menggunakan DROP STATISTICS. Statistik tetap selama indeks ada.

Untuk informasi selengkapnya tentang menampilkan statistik, lihat DBCC SHOW_STATISTICS (Transact-SQL).

Izin

Memerlukan izin ALTER pada tabel atau tampilan.

Contoh

J. Menghilangkan statistik dari tabel

Contoh berikut menghilangkan grup statistik (koleksi) dari dua tabel. VendorCredit Grup statistik (koleksi) Vendor tabel dan CustomerTotal statistik (koleksi) SalesOrderHeader tabel dihilangkan.

-- Create the statistics groups.  
USE AdventureWorks2022;  
GO  
CREATE STATISTICS VendorCredit  
    ON Purchasing.Vendor (Name, CreditRating)  
    WITH SAMPLE 50 PERCENT  
CREATE STATISTICS CustomerTotal  
    ON Sales.SalesOrderHeader (CustomerID, TotalDue)  
    WITH FULLSCAN;  
GO  
DROP STATISTICS Purchasing.Vendor.VendorCredit, Sales.SalesOrderHeader.CustomerTotal;  

Contoh: Azure Synapse Analytics and Analytics Platform System (PDW)

B. Menghilangkan statistik dari tabel

Contoh berikut menghilangkan CustomerStats1 statistik dari tabel Customer.

DROP STATISTICS Customer.CustomerStats1;  
DROP STATISTICS dbo.Customer.CustomerStats1;  

Lihat Juga

MENGUBAH DATABASE (T-SQL)
BUAT INDEKS (Transact-SQL)
MEMBUAT STATISTIK (Transact-SQL)
sys.stats (Transact-SQL)
sys.stats_columns (T-SQL)
DBCC SHOW_STATISTICS (Transact-SQL)
sp_autostats (T-SQL)
sp_createstats (T-SQL)
PERBARUI STATISTIK (Transact-SQL)
EVENTDATA (Transact-SQL)
USE (Transact-SQL)
Statistik di Microsoft Fabric