CREATE STATISTICS

Create statistics for one or more table columns in the current database.

Syntax
      CREATE STATISTICS statistics 
         ON {table | view} (column [,...n] )
            [WITH option  [NORECOMPUTE] ];

   Options: 
           FULLSCAN 
           SAMPLE number {PERCENT | ROWS} 
           STATS_STREAM = stats_stream ] [,]  

Key
   statistics     The name of the statistics group to create
   table/view     The item for which statistics should be created
   column         The column(s) on which to create statistics. (not xml column) 
   FULLSCAN       Read all rows in table.
   SAMPLE         Read a percentage, or a specified random number of rows.
   NORECOMPUTE    Do not automatically recompute statistics.

The statistics include a histogram and associated density groups (collections) over the column(s).

Examples

CREATE STATISTICS MyStats
ON MySchema.MyTable (ColID, Coltext)
WITH SAMPLE 5 PERCENT;

"There are lies, damned lies, and statistics" - Disraeli

Related commands

DROP STATISTICS
DBCC SHOW_STATISTICS
Equivalent Oracle command: ASSOCIATE STATISTICS


 
Copyright © 1999-2024 SS64.com
Some rights reserved