CREATE STATISTICS (Transact-SQL)CREATE STATISTICS (Transact-SQL)

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse

在表格、索引视图或外部表格的一列或多列上创建查询优化统计信息。Creates query optimization statistics on one or more columns of a table, an indexed view, or an external table. 对于大多数查询,查询优化器已为高质量查询计划生成必要的统计信息;在少数情况下,您需要使用 CREATE STATISTICS 创建附加的统计信息或修改查询设计以提高查询性能。For most queries, the query optimizer already generates the necessary statistics for a high-quality query plan; in a few cases, you need to create additional statistics with CREATE STATISTICS or modify the query design to improve query performance.

若要了解更多信息,请参阅统计信息To learn more, see Statistics.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

-- Syntax for SQL Server and Azure SQL Database  
  
-- Create statistics on an external table  
CREATE STATISTICS statistics_name   
ON { table_or_indexed_view_name } ( column [ ,...n ] )   
    [ WITH FULLSCAN ] ;  
  
-- Create statistics on a regular table or indexed view  
CREATE STATISTICS statistics_name   
ON { table_or_indexed_view_name } ( column [ ,...n ] )   
    [ WHERE <filter_predicate> ]  
    [ WITH   
        [ [ FULLSCAN   
            [ [ , ] PERSIST_SAMPLE_PERCENT = { ON | OFF } ]    
          | SAMPLE number { PERCENT | ROWS }   
            [ [ , ] PERSIST_SAMPLE_PERCENT = { ON | OFF } ]    
          | <update_stats_stream_option> [ ,...n ]    
        [ [ , ] NORECOMPUTE ]   
        [ [ , ] INCREMENTAL = { ON | OFF } ] 
        [ [ , ] MAXDOP = max_degree_of_parallelism ]
    ] ;  
  
<filter_predicate> ::=   
    <conjunct> [AND <conjunct>]  
  
<conjunct> ::=  
    <disjunct> | <comparison>  
  
<disjunct> ::=  
        column_name IN (constant ,...)  
  
<comparison> ::=  
        column_name <comparison_op> constant  
  
<comparison_op> ::=  
    IS | IS NOT | = | <> | != | > | >= | !> | < | <= | !<  
    
<update_stats_stream_option> ::=  
    [ STATS_STREAM = stats_stream ]  
    [ ROWCOUNT = numeric_constant ]  
    [ PAGECOUNT = numeric_contant ] 
-- Syntax for Azure Synapse Analytics and Parallel Data Warehouse  
  
CREATE STATISTICS statistics_name   
    ON { database_name.schema_name.table_name | schema_name.table_name | table_name }
    ( column_name  [ ,...n ] )   
    [ WHERE <filter_predicate> ]  
    [ WITH {  
           FULLSCAN   
           | SAMPLE number PERCENT   
      }  
    ]  
[;]  
  
<filter_predicate> ::=   
    <conjunct> [AND <conjunct>]  
  
<conjunct> ::=  
    <disjunct> | <comparison>  
  
<disjunct> ::=  
        column_name IN (constant ,...)  
  
<comparison> ::=  
        column_name <comparison_op> constant  
  
<comparison_op> ::=  
    IS | IS NOT | = | <> | != | > | >= | !> | < | <= | !<  

备注

若要查看 SQL Server 2014 及更早版本的 Transact-SQL 语法,请参阅早期版本文档To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.

参数Arguments

statistics_namestatistics_name
是要创建的统计信息的名称。Is the name of the statistics to create.

table_or_indexed_view_nametable_or_indexed_view_name
在其上创建统计信息的表格、索引视图或外部表格的名称。Is the name of the table, indexed view, or external table on which to create the statistics. 若要在另一个数据库中创建统计信息,请指定限定的表名称。To create statistics on another database, specify a qualified table name.

column [ ,...n]column [ ,...n]
统计信息中要包含的一列或多列。One or more columns to be included in the statistics. 这些列按照从左到右的优先顺序排列。The columns should be in priority order from left to right. 仅第一列用于创建直方图。Only the first column is used for creating the histogram. 所有列都可用于调用密度的跨列相关性统计信息。All columns are used for cross-column correlation statistics called densities.

您可以指定任何可指定为索引键列的列,但下列情况除外:You can specify any column that can be specified as an index key column with the following exceptions:

  • 不能指定 Xml、全文和 FILESTREAM 列。Xml, full-text, and FILESTREAM columns cannot be specified.

  • 只有当 ARITHABORT 和 QUOTED_IDENTIFIER 数据库设置为 ON 时,才能指定计算列。Computed columns can be specified only if the ARITHABORT and QUOTED_IDENTIFIER database settings are ON.

  • 如果 CLR 用户定义类型支持二进制排序,则可以指定 CLR 用户定义类型列。CLR user-defined type columns can be specified if the type supports binary ordering. 如果方法具有确定性标记,可以指定定义为用户定义类型的列的方法调用的计算列。Computed columns defined as method invocations of a user-defined type column can be specified if the methods are marked deterministic.

WHERE <filter_predicate> 指定一个表达式,以选择在创建统计信息对象时要包括的行的子集。WHERE <filter_predicate> Specifies an expression for selecting a subset of rows to include when creating the statistics object. 使用筛选谓词创建的统计信息称作筛选统计信息。Statistics that are created with a filter predicate are called filtered statistics. 筛选器谓词使用简单比较逻辑且不能引用计算列、UDT 列、空间数据类型列或 hierarchyID 数据类型列。The filter predicate uses simple comparison logic and cannot reference a computed column, a UDT column, a spatial data type column, or a hierarchyID data type column. 比较运算符不允许使用 NULL 文本的比较。Comparisons using NULL literals are not allowed with the comparison operators. 请改用 IS NULL 和 IS NOT NULL 运算符。Use the IS NULL and IS NOT NULL operators instead.

下面是 Production.BillOfMaterials 表的筛选谓词的一些示例:Here are some examples of filter predicates for the Production.BillOfMaterials table:

  • WHERE StartDate > '20000101' AND EndDate <= '20000630'

  • WHERE ComponentID IN (533, 324, 753)

  • WHERE StartDate IN ('20000404', '20000905') AND EndDate IS NOT NULL

有关筛选器谓词的详细信息,请参阅创建筛选索引For more information about filter predicates, see Create Filtered Indexes.

FULLSCANFULLSCAN
扫描所有行,计算统计信息。Compute statistics by scanning all rows. FULLSCAN 和 SAMPLE 100 PERCENT 的结果相同。FULLSCAN and SAMPLE 100 PERCENT have the same results. FULLSCAN 不能与 SAMPLE 选项一起使用。FULLSCAN cannot be used with the SAMPLE option.

如果省略,SQL Server 会使用采样创建统计信息,并确定创建高质量查询计划所需的示例大小When omitted, SQL Server uses sampling to create the statistics, and determines the sample size that is required to create a high quality query plan

SAMPLE number { PERCENT | ROWS }SAMPLE number { PERCENT | ROWS }
指定在查询优化器创建统计信息时所使用的表或索引视图中的近似行百分比或行数。Specifies the approximate percentage or number of rows in the table or indexed view for the query optimizer to use when it creates statistics. 对于 PERCENT,number 可以介于 0 到 100 之间,对于 ROWS,number 可以介于 0 到总行数之间 。For PERCENT, number can be from 0 through 100 and for ROWS, number can be from 0 to the total number of rows. 查询优化器抽样的实际行百分比或行数可能与指定的行百分比或行数不匹配。The actual percentage or number of rows the query optimizer samples might not match the percentage or number specified. 例如,查询优化器扫描数据页上的所有行。For example, the query optimizer scans all rows on a data page.

对于基于默认抽样的查询计划并非最佳的特殊情况,SAMPLE 非常有用。SAMPLE is useful for special cases in which the query plan, based on default sampling, is not optimal. 在大多数情况下,不必指定 SAMPLE,这是因为在默认情况下,查询优化器已根据需要采用抽样,并以统计方式确定大量样本的大小,以便创建高质量的查询计划。In most situations, it is not necessary to specify SAMPLE because the query optimizer already uses sampling and determines the statistically significant sample size by default, as required to create high-quality query plans.

SAMPLE 不能与 FULLSCAN 选项一起使用。SAMPLE cannot be used with the FULLSCAN option. 如果未指定 SAMPLE 和 FULLSCAN,查询优化器则默认使用抽样数据并计算样本大小。When neither SAMPLE nor FULLSCAN is specified, the query optimizer uses sampled data and computes the sample size by default.

我们建议不指定 0 PERCENT 或 0 ROWS。We recommend against specifying 0 PERCENT or 0 ROWS. 如果指定 0 PERCENT 或 0 ROWS,则将创建统计信息对象,但该对象不包含任何统计信息数据。When 0 PERCENT or ROWS is specified, the statistics object is created but does not contain statistics data.

PERSIST_SAMPLE_PERCENT = { ON | OFF }PERSIST_SAMPLE_PERCENT = { ON | OFF }
为 ON 时,统计信息将保留创建采样百分比,用于未明确指定采样百分比的后续更新。When ON, the statistics will retain the creation sampling percentage for subsequent updates that do not explicitly specify a sampling percentage. 为 OFF 时,在未明确指定采样百分比的后续更新中,统计信息采样百分比将重置为默认采样。When OFF, statistics sampling percentage will get reset to default sampling in subsequent updates that do not explicitly specify a sampling percentage. 默认为 OFFThe default is OFF.

备注

如果该表被截断,则截断的 HoBT 上生成的所有统计信息将恢复为使用默认采样百分比。If the table is truncated, all statistics built on the truncated HoBT will revert to using the default sampling percentage.

适用于SQL Server 2016 (13.x)SQL Server 2016 (13.x)(从 SQL Server 2016 (13.x)SQL Server 2016 (13.x) SP1 CU4 开始)及更高版本(从 SQL Server 2017 (14.x)SQL Server 2017 (14.x) CU1 开始)。Applies to: SQL Server 2016 (13.x)SQL Server 2016 (13.x) (starting with SQL Server 2016 (13.x)SQL Server 2016 (13.x) SP1 CU4) and later (starting with SQL Server 2017 (14.x)SQL Server 2017 (14.x) CU1).

STATS_STREAM stats_stream = STATS_STREAM =stats_stream

标识为仅供参考。Identified for informational purposes only. 不支持。Not supported. 不保证以后的兼容性。Future compatibility is not guaranteed.

NORECOMPUTENORECOMPUTE
为 statistics_name 禁用自动统计信息更新选项 AUTO_STATISTICS_UPDATE。Disable the automatic statistics update option, AUTO_STATISTICS_UPDATE, for statistics_name. 如果指定了该选项,则查询优化器将完成 statistics_name 的任何正在进行中的统计信息更新并禁止在将来出现更新。If this option is specified, the query optimizer will complete any in-progress statistics updates for statistics_name and disable future updates.

若要重新启用统计信息更新,请使用 DROP STATISTICS 删除统计信息,然后运行 CREATE STATISTICS 但不使用 NORECOMPUTE 选项。To re-enable statistics updates, remove the statistics with DROP STATISTICS and then run CREATE STATISTICS without the NORECOMPUTE option.

警告

使用此选项可能会产生并非最佳的查询计划。Using this option can produce suboptimal query plans. 建议您尽量少用此选项,并且此选项只能由有资格的系统管理员使用。We recommend using this option sparingly, and then only by a qualified system administrator.

有关 AUTO_STATISTICS_UPDATE 选项的详细信息,请参阅 ALTER DATABASE SET 选项 (Transact-SQL)For more information about the AUTO_STATISTICS_UPDATE option, see ALTER DATABASE SET Options (Transact-SQL). 有关禁用和重新启用统计信息更新的详细信息,请参阅统计信息For more information about disabling and re-enabling statistics updates, see Statistics.

INCREMENTAL = { ON | OFF }INCREMENTAL = { ON | OFF }
为 ON 时,根据分区统计信息创建统计信息。When ON, the statistics created are per partition statistics. 为 OFF 时,为所有分区合并统计信息。When OFF, stats are combined for all partitions. 默认为 OFFThe default is OFF.

如果不支持每个分区统计信息,将生成错误。If per partition statistics are not supported an error is generated. 对于以下统计信息类型,不支持增量统计信息:Incremental stats are not supported for following statistics types:

  • 使用未与基表的分区对齐的索引创建的统计信息。Statistics created with indexes that are not partition-aligned with the base table.
  • 对 Always On 可读辅助数据库创建的统计信息。Statistics created on Always On readable secondary databases.
  • 对只读数据库创建的统计信息。Statistics created on read-only databases.
  • 对筛选的索引创建的统计信息。Statistics created on filtered indexes.
  • 对视图创建的统计信息。Statistics created on views.
  • 对内部表创建的统计信息。Statistics created on internal tables.
  • 使用空间索引或 XML 索引创建的统计信息。Statistics created with spatial indexes or XML indexes.

适用于SQL Server 2014 (12.x)SQL Server 2014 (12.x) 及更高版本。Applies to: SQL Server 2014 (12.x)SQL Server 2014 (12.x) and later.

MAXDOP = max_degree_of_parallelismMAXDOP = max_degree_of_parallelism
适用对象SQL ServerSQL Server(从 SQL Server 2016 (13.x)SQL Server 2016 (13.x) SP2 和 SQL Server 2017 (14.x)SQL Server 2017 (14.x) CU3 开始)。Applies to: SQL ServerSQL Server (Starting with SQL Server 2016 (13.x)SQL Server 2016 (13.x) SP2 and SQL Server 2017 (14.x)SQL Server 2017 (14.x) CU3).

在统计信息操作期间替代最大并行度配置选项。Overrides the max degree of parallelism configuration option for the duration of the statistic operation. 有关详细信息,请参阅 配置 max degree of parallelism 服务器配置选项For more information, see Configure the max degree of parallelism Server Configuration Option. 使用 MAXDOP 可以限制在执行并行计划的过程中使用的处理器数量。Use MAXDOP to limit the number of processors used in a parallel plan execution. 最大数量为 64 个处理器。The maximum is 64 processors.

max_degree_of_parallelism 可以是:max_degree_of_parallelism can be:

11
取消生成并行计划。Suppresses parallel plan generation.

>1>1
基于当前系统工作负载,将并行统计信息操作中使用的最大处理器数限制为指定数量或更少。Restricts the maximum number of processors used in a parallel statistic operation to the specified number or fewer based on the current system workload.

0(默认值)0 (default)
根据当前系统工作负荷使用实际的处理器数量或更少数量的处理器。Uses the actual number of processors or fewer based on the current system workload.

<update_stats_stream_option> 标识为仅供参考。Identified for informational purposes only. 不支持。Not supported. 不保证以后的兼容性。Future compatibility is not guaranteed.<update_stats_stream_option> 标识为仅供参考。Identified for informational purposes only. 不支持。Not supported. 不保证以后的兼容性。Future compatibility is not guaranteed.

权限Permissions

需要以下权限之一:Requires one of these permissions:

  • ALTER TABLEALTER TABLE
  • 用户是表所有者User is the table owner
  • 具有 db_ddladmin 固定数据库角色的成员身份Membership in the db_ddladmin fixed database role

一般备注General Remarks

SQL ServerSQL Server 可使用 tempdb 在生成统计信息之前对已抽样的行进行排序。can use tempdb to sort the sampled rows before building statistics.

外部表的统计信息Statistics for external tables

创建外部表统计信息时,SQL ServerSQL Server先将外部表导入到临时SQL ServerSQL Server表中,然后再创建统计信息。When creating external table statistics, SQL ServerSQL Server imports the external table into a temporary SQL ServerSQL Server table, and then creates the statistics. 对于示例统计信息,仅导入已采样的行。For samples statistics, only the sampled rows are imported. 如果有一个大的外部表格,使用默认采样比使用完全扫描选项要快得多。If you have a large external table, it will be much faster to use the default sampling instead of the full scan option.

具有筛选条件的统计信息Statistics with a filtered condition

筛选统计信息可以提高以下从定义完善的数据子集选择数据的查询的查询性能。Filtered statistics can improve query performance for queries that select from well-defined subsets of data. 筛选的统计信息在 WHERE 子句中使用筛选谓词来选择统计信息中包含的数据子集。Filtered statistics use a filter predicate in the WHERE clause to select the subset of data that is included in the statistics.

何时使用 CREATE STATISTICSWhen to Use CREATE STATISTICS

有关何时使用 CREATE STATISTICS 的详细信息,请参阅统计信息For more information about when to use CREATE STATISTICS, see Statistics.

筛选统计信息的引用依赖项Referencing Dependencies for Filtered Statistics

sys.sql_expression_dependencies 目录视图将筛选统计信息谓词中的每一列作为一个引用依赖项,进行跟踪。The sys.sql_expression_dependencies catalog view tracks each column in the filtered statistics predicate as a referencing dependency. 由于您无法删除、重命名或修改在筛选统计信息谓词中定义的表列的定义,因此在创建筛选统计信息之前应考虑清楚要对表列执行哪些操作。Consider the operations that you perform on table columns before creating filtered statistics because you cannot drop, rename, or alter the definition of a table column that is defined in a filtered statistics predicate.

限制和局限Limitations and Restrictions

  • 外部表格中不支持更新统计信息。Updating statistics is not supported on external tables. 若要更新外部表格中的统计信息,请删除并重新创建统计信息。To update statistics on an external table, drop and re-create the statistics.
  • 每个统计信息对象至多可列出 64 列。You can list up to 64 columns per statistics object.
  • MAXDOP 选项与 STATS_STREAM、ROWCOUNT 和 PAGECOUNT 选项不兼容。The MAXDOP option is not compatible with STATS_STREAM, ROWCOUNT and PAGECOUNT options.
  • 如果使用,MAXDOP 选项会受 Resource Governor 工作负载组 MAX_DOP 设置的限制。The MAXDOP option is limited by the Resource Governor workload group MAX_DOP setting, if used.
  • Azure SQL 数据库中不支持外部表上的 CREATE 和 DROP STATISTICS。CREATE and DROP STATISTICS on external tables are not supported in Azure SQL Database.

示例Examples

使用 AdventureWorks 数据库示例。Examples use the AdventureWorks database.

A.A. 将 CREATE STATISTICS 与 SAMPLE number PERCENT 一起使用Using CREATE STATISTICS with SAMPLE number PERCENT

下例使用 AdventureWorks2012AdventureWorks2012 数据库中 Person 表的 BusinessEntityIDEmailPromotion 列的 5% 作为随机抽样来创建 ContactMail1 统计信息。The following example creates the ContactMail1 statistics, using a random sample of 5 percent of the BusinessEntityID and EmailPromotion columns of the Person table of the AdventureWorks2012AdventureWorks2012 database.

CREATE STATISTICS ContactMail1  
    ON Person.Person (BusinessEntityID, EmailPromotion)  
    WITH SAMPLE 5 PERCENT;  

B.B. 将 CREATE STATISTICS 与 FULLSCAN 和 NORECOMPUTE 一起使用Using CREATE STATISTICS with FULLSCAN and NORECOMPUTE

以下示例对 NamePurchase 表的 BusinessEntityIDEmailPromotion 列中的所有行创建 Person 统计信息,并禁用自动重新计算统计信息。The following example creates the NamePurchase statistics for all rows in the BusinessEntityID and EmailPromotion columns of the Person table and disables automatic recomputing of statistics.

CREATE STATISTICS NamePurchase  
    ON AdventureWorks2012.Person.Person (BusinessEntityID, EmailPromotion)  
    WITH FULLSCAN, NORECOMPUTE;  

C.C. 使用 CREATE STATISTICS 创建筛选统计信息Using CREATE STATISTICS to create filtered statistics

以下示例创建筛选统计信息 ContactPromotion1The following example creates the filtered statistics ContactPromotion1. 数据库引擎Database Engine对 50% 的数据进行采样,然后选择 EmailPromotion 等于 2 的行。The 数据库引擎Database Engine samples 50 percent of the data and then selects the rows with EmailPromotion equal to 2.

CREATE STATISTICS ContactPromotion1  
    ON Person.Person (BusinessEntityID, LastName, EmailPromotion)  
WHERE EmailPromotion = 2  
WITH SAMPLE 50 PERCENT;  
GO  

D.D. 在外部表上创建统计信息Create statistics on an external table

在外部表上创建统计信息时,除了提供列的列表,唯一需要做的决定是通过对行采样创建统计数据,还是通过扫描所有行创建统计数据。The only decision you need to make when you create statistics on an external table, besides providing the list of columns, is whether to create the statistics by sampling the rows or by scanning all of the rows. Azure SQL 数据库中不支持外部表上的 CREATE 和 DROP STATISTICS。CREATE and DROP STATISTICS on external tables are not supported in Azure SQL Database.

由于 SQL ServerSQL Server 将外部表中的数据导入临时表,创建统计信息,所以完全扫描选项所需时间更长。Since SQL ServerSQL Server imports data from the external table into a temporary table to create statistics, the full scan option will take much longer. 对于大型表格来说,通常情况下,使用默认采样方法就够了。For a large table, the default sampling method is usually sufficient.

--Create statistics on an external table and use default sampling.  
CREATE STATISTICS CustomerStats1 ON DimCustomer (CustomerKey, EmailAddress);  
  
--Create statistics on an external table and scan all the rows  
CREATE STATISTICS CustomerStats1 ON DimCustomer (CustomerKey, EmailAddress) WITH FULLSCAN;  

E.E. 将 CREATE STATISTICS 与 FULLSCAN 和 PERSIST_SAMPLE_PERCENT 一起使用Using CREATE STATISTICS with FULLSCAN and PERSIST_SAMPLE_PERCENT

以下示例为 PersonBusinessEntityIDEmailPromotion 列中的所有行创建 NamePurchase 统计信息,并为所有未明确指定采样百分比的后续更新设置 100% 的采样百分比。The following example creates the NamePurchase statistics for all rows in the BusinessEntityID and EmailPromotion columns of the Person table and sets a 100 percent sampling percentage for all subsequent updates that do not explicitly specify a sampling percentage.

CREATE STATISTICS NamePurchase  
    ON AdventureWorks2012.Person.Person (BusinessEntityID, EmailPromotion)  
    WITH FULLSCAN, PERSIST_SAMPLE_PERCENT = ON;  

使用 AdventureWorksDW 数据库的示例。Examples using AdventureWorksDW database.

F.F. 在两列中创建统计信息Create statistics on two columns

以下示例基于 DimCustomerCustomerKeyEmailAddress 列创建 CustomerStats1 统计信息。The following example creates the CustomerStats1 statistics, based on the CustomerKey and EmailAddress columns of the DimCustomer table. 此统计信息是基于 Customer 表的行中具有重大统计意义的采样而创建的。The statistics are created based on a statistically significant sampling of the rows in the Customer table.

CREATE STATISTICS CustomerStats1 ON DimCustomer (CustomerKey, EmailAddress);  

G.G. 使用完全扫描创建统计信息Create statistics by using a full scan

以下示例扫描 DimCustomer 表中的所有行,创建 CustomerStatsFullScan 统计信息。The following example creates the CustomerStatsFullScan statistics, based on scanning all of the rows in the DimCustomer table.

CREATE STATISTICS CustomerStatsFullScan 
ON DimCustomer (CustomerKey, EmailAddress) WITH FULLSCAN;  

H.H. 指定采样百分比,创建统计信息Create statistics by specifying the sample percentage

以下示例扫描 DimCustomer 表中 50% 的行,创建 CustomerStatsSampleScan 统计信息。The following example creates the CustomerStatsSampleScan statistics, based on scanning 50 percent of the rows in the DimCustomer table.

CREATE STATISTICS CustomerStatsSampleScan 
ON DimCustomer (CustomerKey, EmailAddress) WITH SAMPLE 50 PERCENT;  

另请参阅See Also

统计信息 Statistics
UPDATE STATISTICS (Transact-SQL) UPDATE STATISTICS (Transact-SQL)
sp_updatestats (Transact-SQL) sp_updatestats (Transact-SQL)
DBCC SHOW_STATISTICS (Transact-SQL) DBCC SHOW_STATISTICS (Transact-SQL)
DROP STATISTICS (Transact-SQL) DROP STATISTICS (Transact-SQL)
sys.stats (Transact-SQL) sys.stats (Transact-SQL)
sys.stats_columns (Transact-SQL)sys.stats_columns (Transact-SQL)