Condividi tramite


STATISTICHE DI DROP (Transact-SQL)

Si applica a:SQL ServerDatabase SQL di AzureIstanza gestita di SQL di AzureAzure Synapse AnalyticsPiattaforma di analisi (PDW)Endpoint di analisi SQL in Microsoft FabricMagazzino in Microsoft FabricDatabase SQL in Microsoft Fabric

Elimina le statistiche di più raccolte all'interno delle tabelle specificate del database corrente.

Nota

Per altre informazioni sulle statistiche in Microsoft Fabric, vedere Statistiche in Microsoft Fabric.

Convenzioni relative alla sintassi Transact-SQL

Sintassi

-- 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   
[;]  

Argomenti

tavolo | vista
Nome della tabella o vista indicizzata di destinazione di cui si desidera eliminare le statistiche. I nomi delle tabelle e delle viste devono essere conformi alle regole per gli identificatori di database. Il nome del proprietario della tabella o vista è facoltativo.

statistics_name
Nome del gruppo di statistiche da eliminare. I nomi dei gruppi di statistiche devono essere conformi alle regole per gli identificatori.

Osservazioni:

Eliminare le statistiche con cautela, in quanto l'operazione può influire sul piano di esecuzione scelto da Query Optimizer.

Le statistiche negli indici non possono essere eliminate tramite DROP STATISTICS. Le statistiche vengono mantenute per tutta l'esistenza dell'indice.

Per altre informazioni sulla visualizzazione delle statistiche, vedere DBCC SHOW_STATISTICS (Transact-SQL).

Autorizzazioni

È richiesta l'autorizzazione ALTER per la tabella o la vista.

Esempi

R. Eliminazione di statistiche da una tabella

Nell'esempio seguente vengono eliminati i gruppi (raccolte) di statistiche di due tabelle, ossia il gruppo (raccolta) di statistiche VendorCredit della tabella Vendor e il gruppo (raccolta) di statistiche CustomerTotal della tabella SalesOrderHeader.

-- 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;  

Esempi: Azure Synapse Analytics e Piattaforma di strumenti analitici (PDW)

B. Eliminazione di statistiche da una tabella

Nell'esempio seguente vengono eliminate le statistiche di CustomerStats1 dalla tabella Customer.

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

Vedi anche

ALTER DATABASE (Transact-SQL)
CREA INDICE (Transact-SQL)
CREATE STATISTICS (Transact-SQL)
sys.stats (Transact-SQL)
sys.stats_columns (Transact-SQL)
DBCC SHOW_STATISTICS (Transact-SQL)
sp_autostats (Transact-SQL)
sp_createstats (Transact-SQL)
STATISTICHE AGGIORNATE (Transact-SQL)
DATI EVENTO (Transact-SQL)
USA (Transact-SQL)
Statistiche in Microsoft Fabric