Creating an index
Use the Create Index window to create an index.
Authorities and privileges
To create an index:
-
Open the Create Index window.
-
Specify required properties on the Index page.
-
Optional: Specify optional properties on the Properties
page .
-
Specify storage allocation properties on the Index Space
Management page.
-
If you are creating a partitioned index, specify partition
properties on the Partition Management page. (If the target space is
nonpartitioned, then this tab is not available.)
-
Click OK.
Related information
To specify general properties on the Index page:
-
Identify the index and the target table:
-
In the Index owner field, specify a user ID of the person who will
own the index.
Tip: To display a list of existing objects,
click the
(Browse)
push button next to the field. Select an existing object from
the list.
-
In the Index name field, type a name for the index. Do not use the
name of an existing index at the current server. If you type more than
eight characters, only the first eight are used in the name.
-
In the Table owner field, specify the user ID of the person who
owns the table on which you are creating an index.
-
In the Table name field, type or select the name of the table on
which you are creating an index. (Use the unqualified identifier for the
table.)
Tip: To display a list of existing objects, click on
the
(Browse) push button next to the field. Select an existing object from
the list.
-
Select an Index type from the radio buttons:
Recommendation: To ease migration to future releases of DB2,
specify type 2 index.
-
Type 2
-
Use type 2 indexes whenever possible. Type 2 indexes
provide functions that are unavailable with type 1 indexes, such as:
-
Row locking on the table space
-
UR isolation for an access path
-
Processing of queries by multiple parallel tasks
-
Concurrent access to separate logical partitions
-
Type 1
-
Do not specify type 1 if the identified table:
-
Has a LOCKSIZE of ROW
-
Is in a large partitioned table space
-
Has an ASCII encoding scheme
-
Select columns for the index key:
-
In the Available columns list box, select the column or columns
that you want to define as part of the index key.
-
Click on the <,>,<<, or >> push button
to move the selected column or columns to the Selected columns list box.
-
Use the Move Up and Move Down push buttons to change the
order of items in the Selected columns list box. The order in which
the columns appear in the Selected columns list box is the order
in which the index is created.
-
Optional: Use the Ascending and Descending radio buttons
to specify the search order for each index key.
-
Optional: Select the Unique check box to ensure that two or more
rows of the index key do not contain data with the same value. If you select
the Unique check box, the Do not apply uniqueness constraint
to null valued key check box is enabled.
Important: If the table contains rows with duplicate key values,
the index cannot be created with the uniqueness constraint.
-
If you do not want to force the uniqueness constraint on rows that contain
a null value, select the Do not apply uniqueness constraint to null
valued key check box.
-
If you have data that needs to be viewed as a group or in sequence, select
the Cluster by index values check box. Do not select the Cluster
by index values check box if an existing index on the table already
uses it.
-
Optional: Select the Build index later check box to defer building
the index. If you defer building the index, you can build it later using
the recover index utility.
Recommendation: If your table is populated and the index is
nonunique, then you should defer the index build. If your table is populated
and the index is unique, however, you should not select the Build index
later check box.
Specifying optional properties
To specify optional properties on the Properties page:
-
If you selected index type 1, specify the Number of subpages
for each physical page. If you selected index type 2, this field is not
available.
The number specifies the unit of index locking that DB2 uses for each
physical page. Type 1, 2, 4, 8, or 16. In a data sharing environment you
must specify 1.
-
In the Buffer pool field, specify a buffer pool for your index.
You must specify an active 4 KB buffer pool. The default buffer pool is
the database's buffer pool, unless the uses a 32 KB buffer pool. If the
index cannot use the database's buffer pool by default, then BP0 is used.
Important: The privilege set must contain SYSADM authority,
SYSCTL authority, or USE privileges on the specified buffer pool.
-
In the Data set password field, type the password for the VSAM data
sets. This password is defined through access method services. If you use
storage groups, this password is the password that protects the data as
well as the password that is passed to access method services when
DB2 uses the data sets. If the index occupies multiple data sets, these
data sets must have the same password.
Important: The password setting does not apply to data sets that
are managed by the Storage Management Subsystem (SMS). RACF or a similar
external security system protects data sets defined to SMS.
-
Select the maximum data set size for nonpartitioned indexes. If you selected
Cluster by index values, this field is unavailable.
-
Optional: Select the Close eligible data sets check box. This value
sets the priority for determining which data sets DB2 should close. Select
the check box if you want DB2 to close data sets when the index is not
being used or when the limit on the number of open data sets is reached.
If you select the Close eligible data sets check box, then,
when the conditions are met, DB2 will close the data sets for the least
recently used index spaces before it closes the data sets for index spaces
that are defined with No. If the limit is reached, and there are
indexes with the close eligible data sets setting, then DB2
closes indexes without the close eligible data sets setting.
Specifying storage allocation properties
To specify storage allocation properties:
-
In the Index Space Management page, select Managed by user or Managed
by DB2 from the Data Set Management radio buttons.
-
If you selected Managed by user, type or select the Catalog
name. The name specifies the integrated catalog facility where the data
sets for this indexed are catalogued. If the catalog name is greater than
eight characters, then you must use an alias for this setting.
-
If you selected Managed by DB2:
-
Type or select a storage group name
The storage group must be defined at the current server and it must
include at least one volume serial number in its description.
Important: The privilege set must contain SYSADM authority,
SYSCTL authority, or USE privileges on the specified storage group.
-
Type the Minimum primary space allocation.
This value should be an integer between 12 and 4194304, inclusive.
Smaller or larger values will use 12 or 4194304, respectively.
-
Type the Minimum Secondary space allocation.
If you want DB2 enabled to extend the data set for the index if necessary,
this value should be an integer between 12 and 131068, inclusive. If you
specify 0, DB2 cannot extend the data set. If you specify a Minimum
primary space and do not specify this value, then DB2 calculates a
default secondary space allocation. The default is the larger of two values:
(1) 10 percent of the minimum primary space allocation or (2) 3 times the
index page size, which is 3 * 4KB.
-
Select Yes or No from the Erase data sets when the index
is dropped radio button.
-
If you want to explicitly manage free space in the index space, select
the Specify management scheme for free space check box.
-
Specify a value in the Free space reserved field
-
Specify a value inthe Percentage of free space in a page field.
-
From the Cache pages in a group buffer pool radio buttons, select:
-
Only on Update (CHANGED)
-
When more that one DB2 member has the index or partition open and at least
one member has the index open for an UPDATE operations, updated pages are
written to the group buffer pool.
-
Always cache pages (ALL)
-
Pages are cached in the group buffer when read in from DASD.
Important: These values are ignored and no pages are cached if the
group buffer pool is defined for cross-invalidation use only.
Specifying partition management
properties
Use the Partition Management page to manage
space at the partitions level.
This page is available only if you:
-
Specify a table in partitioned table space in the
Index page.
-
Select an available column and add it to the Selected
columns list.
-
Select the Cluster by index values check box.
The Data management at partition level at partition
table displays the defined partition management settings.
-
To add an entry, click the Add push button,
which opens the Add partition management window.
-
To remove an entry, click the Remove push
button.
-
To change the selected entry, click the Change
push button, which opens the Change partition management window.