sp_chgattribute

Description

Changes the max_rows_per_page, fillfactor, reservepagegap, or exp_row_size value for future space allocations of a table or an index; sets the concurrency_opt_threshold for a table.

Syntax

sp_chgattribute objname, {"max_rows_per_page" | "fillfactor" | 
	"reservepagegap" | "exp_row_size"
	concurrency_opt_threshold }, optvalue
sp_chgattribute "table_name", "identity_gap", set_number

Parameters

objname

is the name of the table or index for which you want to change attributes.

max_rows_per_page

specifies the row size. Use this option for tables with variable-length columns.

fillfactor

specifies how full Adaptive Server will make each page when it is re-creating an index or copying table pages as a result of a reorg rebuild command or an alter table command to change the locking scheme. The fillfactor percentage is relevant only at the time the index is rebuilt. Valid values are 0–100.

reservepagegap

specifies the ratio of filled pages to empty pages that are to be left during extent I/O allocation operations. For each specified num_pages, an empty page is left for future expansion of the table. Valid values are 0–255. The default value is 0.

exp_row_size

reserves a specified amount of space for the rows in data-only locked tables. Use this option to reduce the number of rows being forwarded, which can be expensive during updates. Valid values are 0, 1, and any value between the minimum and maximum row length for the table. 0 means a server-wide setting is applied, and 1 means to fully pack the rows on the data pages.

concurrency_opt_threshold

specifies the table size, in pages, at which access to a data-only-locked table should begin optimizing for reducing I/O, rather than for concurrency. If the table is smaller than the number of pages specified by concurrency_opt_threshold, the query is optimized for concurrency by always using available indexes; if the table is larger than the number of pages specified by concurrency_opt_threshold, the query is optimized for I/O instead. Valid values are -1 to 32767. Setting the value to 0 disables concurrency optimization. Use -1 to enforce concurrency optimization for tables larger than 32767 pages. The default is 15 pages.

optvalue

is the new value. Valid values and default values depend on which parameter is specified.

table_name

is the name of the table for which you want to change the identity gap.

identity_gap

indicates that you want to change the identity gap.

set_number

is the new size of the identity gap.

Examples

Example 1

Sets the max_rows_per_page to 1 for the authors table for all future space allocations:

sp_chgattribute authors, "max_rows_per_page", 1

Example 2

Sets the max_rows_per_page to 4 for the titleidind index for all future space allocations:

sp_chgattribute "titles.titleidind", "max_rows_per_page", 4

Example 3

Specifies a fillfactor of 90 percent for pages in title_ix:

sp_chgattribute "titles.title_ix", "fillfactor", 90

Example 4

Sets the exp_row_size to 120 for the authors table for all future space allocations:

sp_chgattribute authors, "exp_row_size", 120

Example 5

Sets the reservepagegap to 16 for the titleidind index for all future space allocations:

sp_chgattribute "titles.titleidind", "reservepagegap", 16

Example 6

Turns off concurrency optimization for the titles table:

sp_chgattribute "titles", concurrency_opt_threshold, 0

Example 7

Sets the identity gap for mytable to 20:

sp_chgattribute "mytable", "identity_gap", 20

Example 8

Changes mytable to use the identity burning set factor setting instead of the identity_gap setting:

sp_chgattribute "mytable", "identity_gap", 0

Usage

Permissions

Only the object owner can execute sp_chgattribute.

See also

Commands alter table, create index, create table

System procedures sp_helpindex