Académique Documents
Professionnel Documents
Culture Documents
Important:
This feature will be removed in a future version of Microsoft
SQL Server. Avoid using this feature in new development
work, and plan to modify applications that currently use this
feature. Use ALTER INDEX instead.
Syntax
DBCC DBREINDEX
(
'table_name'
[ , 'index_name' [ , fillfactor ] ]
)
[ WITH NO_INFOMSGS ]
Arguments
'table_name'
Is the name of the table for which to rebuild the
specified index or indexes. Table names must follow the
rules for identifiers. database.
'index_name'
Is the name of the index to rebuild. Index names must
comply with the rules for identifiers. If index_name is
specified, table_name must be specified. If index_name
is not specified or is specified as ' ', all indexes for the
table are rebuilt.
fillfactor
Is the percentage of space on each index page to be
used for storing data when the index is created or
rebuilt. fillfactor replaces the fill factor when the index
was created, becoming the new default for the index and
for any other nonclustered indexes rebuilt because a
clustered index is rebuilt. When fillfactor is 0, DBCC
DBREINDEX uses the fill factor value last specified for
the index. This value is stored in the sys.indexes
catalog view.
WITH NO_INFOMSGS
Suppresses all informational messages that have
severity levels from 0 through 10.
Result Sets
Whether any one of the options, except NO_INFOMSGS, is specified (the table name
must be specified), DBCC DBREINDEX returns:
Copy Code
DBCC execution completed. If DBCC printed error
messages, contact your system administrator.
Remarks
DBCC DBREINDEX rebuilds an index for a table or all indexes
defined for a table. By allowing an index to be rebuilt
dynamically, indexes enforcing either PRIMARY KEY or
UNIQUE constraints can be rebuilt without having to drop and
re-create those constraints. This means an index can be
rebuilt without knowing the structure of a table or its
constraints. This might occur after a bulk copy of data into
the table.
Permissions
Caller must own the table, or be a member of the sysadmin
fixed server role, the db_owner fixed database role, or the
db_ddladmin fixed database role.
Examples
A. Rebuilding an index
The following example rebuilds the Employee_EmployeeID
clustered index with a fill factor of 80 on the Employee table
in the AdventureWorks database.
Copy Code
USE AdventureWorks;
GO
DBCC DBREINDEX ('HumanResources.Employee',
PK_Employee_EmployeeID,80);
GO