DB2 10.5 for Linux, UNIX, and Windows

ALTER TABLESPACE statement

The ALTER TABLESPACE statement is used to modify an existing table space.

You can modify a tablespace in the following ways:
  • Add a container to, or drop a container from a DMS table space; that is, a table space created with the MANAGED BY DATABASE option.
  • Modify the size of a container in a DMS table space.
  • Lower the high water mark for a DMS table space through extent movement.
  • Add a container to an SMS table space on a database partition that currently has no containers.
  • Modify the PREFETCHSIZE setting for a table space.
  • Modify the BUFFERPOOL used for tables in the table space.
  • Modify the OVERHEAD setting for a table space.
  • Modify the TRANSFERRATE setting for a table space.
  • Modify the file system caching policy for a table space.
  • Enable or disable auto-resize for a DMS or automatic storage table space.
  • Rebalance a regular or large automatic storage table space.
  • Modify the DATA TAG setting for a table space.
  • Alter a DMS table space to an automatic storage table space.
  • Modify the STOGROUP setting associated with a table space.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared only if DYNAMICRULES run behavior is in effect for the package (SQLSTATE 42509).

Authorization

The privileges held by the authorization ID of the statement must include SYSCTRL or SYSADM authority.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-ALTER TABLESPACE--tablespace-name---------------------------->

   .------------------------------------------------------------------------------------.   
   V                                                                                    |   
>----+-ADD--| add-clause |------------------------------------------------------------+-+-><
     +-BEGIN NEW STRIPE SET--| db-container-clause |--+-----------------------------+-+     
     |                                                '-| on-db-partitions-clause |-' |     
     +-DROP--| drop-container-clause |--+-----------------------------+---------------+     
     |                                  '-| on-db-partitions-clause |-'               |     
     +-REDUCE--+---------------------------+--+-----------------------------+---------+     
     |         +-| db-container-clause |---+  '-| on-db-partitions-clause |-'         |     
     |         +-| all-containers-clause |-+                                          |     
     |         +-MAX-----------------------+                                          |     
     |         +-STOP----------------------+                                          |     
     |         '-integer--+---------+------'                                          |     
     |                    +-K-------+                                                 |     
     |                    +-M-------+                                                 |     
     |                    +-G-------+                                                 |     
     |                    '-PERCENT-'                                                 |     
     +-+-EXTEND-+--+-| db-container-clause |---+--+-----------------------------+-----+     
     | '-RESIZE-'  '-| all-containers-clause |-'  '-| on-db-partitions-clause |-'     |     
     +-REBALANCE--+---------+---------------------------------------------------------+     
     |            +-SUSPEND-+                                                         |     
     |            '-RESUME--'                                                         |     
     +-PREFETCHSIZE--+-AUTOMATIC-------+----------------------------------------------+     
     |               +-number-of-pages-+                                              |     
     |               '-integer--+-K-+--'                                              |     
     |                          '-M-'                                                 |     
     +-BUFFERPOOL--bufferpool-name----------------------------------------------------+     
     +-OVERHEAD--+-number-of-milliseconds-+-------------------------------------------+     
     |           '-INHERIT----------------'                                           |     
     +-TRANSFERRATE--+-number-of-milliseconds-+---------------------------------------+     
     |               '-INHERIT----------------'                                       |     
     +-+-FILE SYSTEM CACHING----+-----------------------------------------------------+     
     | '-NO FILE SYSTEM CACHING-'                                                     |     
     +-DROPPED TABLE RECOVERY--+-ON--+------------------------------------------------+     
     |                         '-OFF-'                                                |     
     +-SWITCH ONLINE------------------------------------------------------------------+     
     +-AUTORESIZE--+-NO--+------------------------------------------------------------+     
     |             '-YES-'                                                            |     
     +-INCREASESIZE--integer--+-PERCENT-+---------------------------------------------+     
     |                        '-+-K-+---'                                             |     
     |                          +-M-+                                                 |     
     |                          '-G-'                                                 |     
     +-MAXSIZE--+-integer--+-K-+-+----------------------------------------------------+     
     |          |          +-M-+ |                                                    |     
     |          |          '-G-' |                                                    |     
     |          '-NONE-----------'                                                    |     
     +-CONVERT TO LARGE---------------------------------------------------------------+     
     +-LOWER HIGH WATER MARK--+------+------------------------------------------------+     
     |                        '-STOP-'                                                |     
     +-USING STOGROUP--storagegroup-name----------------------------------------------+     
     +-DATA TAG--+-integer-constant-+-------------------------------------------------+     
     |           +-INHERIT----------+                                                 |     
     |           '-NONE-------------'                                                 |     
     '-MANAGED BY AUTOMATIC STORAGE---------------------------------------------------'     

add-clause

|--+-+--------------------------+--| db-container-clause |--+-----------------------------+-+--|
   | '-TO STRIPE SET--stripeset-'                           '-| on-db-partitions-clause |-' |   
   '-| system-container-clause |--| on-db-partitions-clause |-------------------------------'   

db-container-clause

      .-,---------------------------------------------------.      
      V                                                     |      
|--(----+-FILE---+--'container-string'--+-number-of-pages-+-+--)--|
        '-DEVICE-'                      '-integer--+-K-+--'        
                                                   +-M-+           
                                                   '-G-'           

drop-container-clause

      .-,------------------------------.      
      V                                |      
|--(----+-FILE---+--'container-string'-+--)---------------------|
        '-DEVICE-'                            

system-container-clause

      .-,------------------.      
      V                    |      
|--(----'container-string'-+--)---------------------------------|

on-db-partitions-clause

|--ON--+-DBPARTITIONNUM--+-------------------------------------->
       '-DBPARTITIONNUMS-'   

      .-,--------------------------------------------------.      
      V                                                    |      
>--(----db-partition-number1--+--------------------------+-+--)--|
                              '-TO--db-partition-number2-'        

all-containers-clause

           .-CONTAINERS-.                           
|--(--ALL--+------------+--+-number-of-pages-+--)---------------|
                           '-integer--+-K-+--'      
                                      +-M-+         
                                      '-G-'         

Description

tablespace-name
Names the table space. This is a one-part name. It is a long SQL identifier (either ordinary or delimited).
ADD
Specifies that one or more new containers are to be added to the table space.
TO STRIPE SET stripeset
Specifies that one or more new containers are to be added to the table space, and that they will be placed into the given stripe set.
BEGIN NEW STRIPE SET
Specifies that a new stripe set is to be created in the table space, and that one or more containers are to be added to this new stripe set. Containers that are subsequently added using the ADD option will be added to this new stripe set unless TO STRIPE SET is specified.
DROP
Specifies that one or more containers are to be dropped from the table space.
REDUCE
For non-automatic storage table spaces, specifies that existing containers are to be reduced in size. The size specified is the size by which the existing container is decreased. If the all-containers-clause is specified, all containers in the table space will decrease by this size. If the reduction in size will result in a table space size that is smaller than the current high water mark, an attempt will be made to reduce the high water mark before attempting to reduce the containers. For non-automatic storage table spaces, the REDUCE clause must be followed by a db-container-clause or an all-containers-clause.

For automatic storage table spaces, specifies that the current high water mark is to be reduced, if possible, and that the size of the table space is to be reduced to the new high water mark. For automatic storage table spaces, the REDUCE clause must not be followed by a db-container-clause, an all-containers-clause or an on-db-partitions-clause.

Note: The REDUCE option with the MAX, numeric value, PERCENT, or STOP clauses, and the LOWER HIGH WATER MARK option including the STOP clause, are only available for database managed, and automatic storage managed, table spaces with the reclaimable storage attribute. Moreover, these options must be specified and run without any other options, including each other.

The MAX, STOP, integer [K | M | G], or integer PERCENT clause takes effect when the statement is processed and is not rolled back if the unit of work, in which the statement is executed, is rolled back.

db-container-clause
Adds one or more containers to a DMS table space. The table space must identify a DMS table space that already exists at the application server.
all-containers-clause
Extends, reduces, or resizes all of the containers in a DMS table space. The table space must identify a DMS table space that already exists at the application server.
MAX
For automatic storage table spaces with reclaimable storage, specifies that the maximum number of extents should be moved to the beginning of the table space to lower the high water mark. Additionally, the size of the table space will be reduced to the new high water mark. This does not apply to non-automatic storage table spaces.
STOP
For automatic storage table spaces with reclaimable storage, interrupts the extent movement operation if in progress. This option is not available for non-automatic storage table spaces.
integer [K | M | G] or integer PERCENT
For automatic storage table spaces with reclaimable storage, specifies the numeric value by which the table space is to be reduced through extent movement. The value can be expressed in several ways:
  • An integer specified without K, M, G, or PERCENT indicates that the numeric value is the number of pages by which the table space is to be reduced.
  • An integer specified with K, M, or G indicates the reduction size in kilobytes, megabytes, or gigabytes, respectively. The value is first converted from bytes to number of pages based on the page size of the table space.
  • An integer specified with PERCENT indicates the number of extents to move, as a percentage of the current size of the table space.
Once extent movement is complete, the table space size is reduced to the new high water mark. This option is not available for non-automatic storage table spaces.
on-db-partitions-clause
Specifies one or more database partitions for the corresponding container operations.
EXTEND
Specifies that existing containers are to be increased in size. The size specified is the size by which the existing container is increased. If the all-containers-clause is specified, all containers in the table space will increase by this size.
RESIZE
Specifies that the size of existing containers is to be changed. The size specified is the new size for the container. If the all-containers-clause is specified, all containers in the table space will be changed to this size. If the operation affects more than one container, these containers must all either increase in size, or decrease in size. It is not possible to increase some while decreasing others (SQLSTATE 429BC).
db-container-clause
Adds one or more containers to a DMS table space. The table space must identify a DMS table space that already exists at the application server.
drop-container-clause
Drops one or more containers from a DMS table space. The table space must identify a DMS table space that already exists at the application server.
system-container-clause
Adds one or more containers to an SMS table space on the specified database partitions. The table space must identify an SMS table space that already exists at the application server. There must not be any containers on the specified database partitions for the table space (SQLSTATE 42921).
on-db-partitions-clause
Specifies one or more database partitions for the corresponding container operations.
all-containers-clause
Extends, reduces, or resizes all of the containers in a DMS table space. The table space must identify a DMS table space that already exists at the application server.
REBALANCE
For regular and large automatic storage table spaces, initiates the creation of containers on recently added storage paths, the drop of containers from storage paths that are in the "Drop Pending" state, or both. During the rebalance, data is moved into containers on new paths, and moved out of containers on dropped paths. The rebalance runs asynchronously in the background and does not affect the availability of data.
Note: The SUSPEND or RESUME clause takes effect when the statement is processed and is not rolled back if the unit of work, in which the statement is executed, is rolled back.
SUSPEND
Suspends the active rebalance operation on the specified table space. If there is no active rebalance operation, no action is taken and success is returned. The suspend state is persistent and if the database is deactivated while the rebalance is suspended, then upon database activation the rebalance operation is restarted from the suspended state. Suspending a rebalance operation when it is already suspended has no effect and success is returned.
RESUME
Resumes a previously suspended rebalance operation. If there is no active rebalance operation, no action is taken and success is returned. If the rebalance is PAUSED because of an online backup operation, then the table space rebalance is taken out of the suspended state but remains paused until the online backup is completed.
PREFETCHSIZE
Specifies to read in data needed by a query before it being referenced by the query, so that the query need not wait for I/O to be performed.
AUTOMATIC
Specifies that the prefetch size of a table space is to be updated automatically; that is, the prefetch size will be managed by the database manager.

The database will update the prefetch size automatically whenever the number of containers in a table space changes (following successful execution of an ALTER TABLESPACE statement that adds or drops one or more containers). The prefetch size is also automatically updated at database startup.

Automatic updating of the prefetch size can be turned off by specifying a numeric value in the PREFETCHSIZE clause.

number-of-pages
Specifies the number of PAGESIZE pages that will be read from the table space when data prefetching is being performed. The maximum value is 32767.
integer K | M
Specifies the prefetch size value as an integer value followed by K (for kilobytes) or M (for megabytes). If specified in this way, the floor of the number of bytes divided by the page size is used to determine the number of pages value for prefetch size.
BUFFERPOOL bufferpool-name
The name of the buffer pool used for tables in this table space. The buffer pool must currently exist in the database (SQLSTATE 42704). The database partition group of the table space must be defined for the bufferpool (SQLSTATE 42735).
OVERHEAD number-of-milliseconds or OVERHEAD INHERIT
Specifies the I/O controller overhead and disk seek and latency time. This value is used to determine the cost of I/O during query optimization.
number-of-milliseconds
Any numeric literal (integer, decimal, or floating point) that specifies the I/O controller overhead and disk seek and latency time, in milliseconds. The number should be an average for all containers that belong to the table space, if not the same for all containers.
INHERIT
If INHERIT is specified, the table space must be defined using automatic storage and the OVERHEAD is dynamically inherited from the storage group. INHERIT cannot be specified if the table space is not defined using automatic storage (SQLSTATE 42858). If the OVERHEAD is set to undefined for the storage group and you set OVERHEAD to INHERIT, the database creation default will be used.

Version 10.1For a database that was created in DB2® or later, the default I/O controller overhead and disk seek and latency time is 6.725 milliseconds.

For a database that was upgraded from a previous version of DB2 to DB2Version 10.1 or later, the default I/O controller overhead and disk seek and latency time is as follows:
  • 7.5 milliseconds for a database created in DB2 version 9.7 or higher
TRANSFERRATE number-of-milliseconds or TRANSFERRATE INHERIT
Specifies the time to read one page into memory. This value is used to determine the cost of I/O during query optimization.
number-of-milliseconds
Any numeric literal (integer, decimal, or floating point) that specifies the time to read one page (4K or 8K) into memory, in milliseconds. The number should be an average for all containers that belong to the table space, if not the same for all containers.
INHERIT
If INHERIT is specified, the table space must be defined using automatic storage and the TRANSFERRATE is dynamically inherited from the storage group. INHERIT cannot be specified if the table space is not defined using automatic storage (SQLSTATE 42858). If the DEVICE READ RATE of the storage group is set to undefined and the user sets TRANSFERRATE to INHERIT, the database creation default will be used.

When an automatic storage table space inherits the TRANSFERRATE setting from the storage group it is using, the DEVICE READ RATE of the storage group, which is in megabytes per second, is converted into milliseconds per page read accounting for the table space's PAGESIZE setting of the table space. The conversion formula follows:

TRANSFERRATE = ( 1 / DEVICE READ RATE ) * 1000 / 1024000 * PAGESIZE

For a database that was created in DB2Version 10.1 or later, the default time to read one page into memory for 4 KB PAGESIZE table space is 0.04 milliseconds.

For a database that was upgraded from a previous version of DB2 to DB2Version 10.1 or later, the default time to read one page into memory is as follows:
  • 0.06 milliseconds for a database created in DB2 version 9.7 or higher
FILE SYSTEM CACHING or NO FILE SYSTEM CACHING
Specifies whether I/O operations will be buffered or non-cached at the file system level. Changes to the I/O mode are not dynamic and will take effect on the next database activation. The default I/O mode is determined based on operating system, filesystem type, and in the case of SMS tablespaces, data object type. See "file system caching configurations" for further information. Note that once a non-default file system caching option is chosen, it is not possible to return to the default (unspecified) behaviour. Instead, the file system caching mode must be selected explicitly.
FILE SYSTEM CACHING
All I/O operations in the target table space will be cached at the file system level.
NO FILE SYSTEM CACHING
Specifies that all I/O operations are to bypass the file system-level cache.  LOB and Long field data in SMS tablespaces are excepted.
Note: You must format the disk device to have a disk sector size according to the following table:
Operating system Disk sector size
AIX® 512 bytes
Solaris 512 bytes
HP-UX 1024 bytes
Linux 512 bytes
Windows 512 bytes
DROPPED TABLE RECOVERY
Specifies whether or not tables that have been dropped from tablespace-name can be recovered using the RECOVER DROPPED TABLE ON option of the ROLLFORWARD DATABASE command. For partitioned tables, dropped table recovery is always on, even if dropped table recovery is turned off for non-partitioned tables in one or more table spaces.
ON
Specifies that dropped tables can be recovered.
OFF
Specifies that dropped tables cannot be recovered.
SWITCH ONLINE
Specifies that table spaces in OFFLINE state are to be brought online if their containers have become accessible. If the containers are not accessible, an error is returned (SQLSTATE 57048).
AUTORESIZE
Specifies whether or not the auto-resize capability of a database managed space (DMS) table space or an automatic storage table space is to be enabled. Auto-resizable table spaces automatically increase in size when they become full.
NO
Specifies that the auto-resize capability of a DMS table space or an automatic storage table space is to be disabled. If the auto-resize capability is disabled, any values that have been previously specified for INCREASESIZE or MAXSIZE will not be kept.
YES
Specifies that the auto-resize capability of a DMS table space or an automatic storage table space is to be enabled.
INCREASESIZE integer PERCENT or INCREASESIZE integer K | M | G
Specifies the amount, per database partition, by which a table space that is enabled for auto-resize will automatically be increased when the table space is full, and a request for space has been made. The integer value must be followed by:
  • PERCENT to specify the amount as a percentage of the table space size at the time that a request for space is made. When PERCENT is specified, the integer value must be between 0 and 100 (SQLSTATE 42615).
  • K (for kilobytes), M (for megabytes), or G (for gigabytes) to specify the amount in bytes
Note that the actual value used might be slightly smaller or larger than what was specified, because the database manager strives to maintain consistent growth across containers in the table space.
MAXSIZE integer K | M | G or MAXSIZE NONE
Specifies the maximum size to which a table space that is enabled for auto-resize can automatically be increased.
integer
Specifies a hard limit on the size, per database partition, to which a DMS table space or an automatic storage table space can automatically be increased. The integer value must be followed by K (for kilobytes), M (for megabytes), or G (for gigabytes). Note that the actual value used might be slightly smaller than what was specified, because the database manager strives to maintain consistent growth across containers in the table space.
NONE
Specifies that the table space is to be allowed to grow to file system capacity, or to the maximum table space size (described in "SQL and XML limits").
CONVERT TO LARGE
Modifies an existing regular DMS table space to be a large DMS table space. The table space and its contents are locked during conversion. This option can only be used on regular DMS table spaces. If an SMS table space, a temporary table space, or the system catalog table space is specified, an error is returned (SQLSTATE 560CF). You cannot convert a table space that contains a data partition of a partitioned table that has data partitions in another table space (SQLSTATE 560CF). Conversion cannot be reversed after being committed. If tables in the table space are defined with DATA CAPTURE CHANGES, consider the storage and capacity limits of the target table and table space.
LOWER HIGH WATER MARK
For both automatic storage and non-automatic storage table spaces with reclaimable storage, triggers the extent movement operation to move the maximum number of extents lower in the table space. Although the high water mark is lowered, the size of the table space is not reduced. This must be followed by an ALTER TABLESPACE REDUCE for automatic storage table spaces or ALTER TABLESPACE REDUCE with the db-container-clause or all-containers-clause for non-automatic storage table spaces.
Note: The LOWER HIGH WATER MARK option including the STOP clause, and the REDUCE option with the MAX, numeric value, PERCENT, or STOP clauses, are only available for database managed and automatic storage managed table spaces with the reclaimable storage attribute. Moreover, these options must be specified and run without any other options, including each other.
Note: This clause takes effect when the statement is processed and is not rolled back if the unit of work, in which the statement is executed, is rolled back.
STOP
For both automatic storage and non-automatic storage table spaces with reclaimable storage, interrupts the extent movement operation if in progress.
USING STOGROUP
Associates a table space with a different storage group. The data associated with the table space will be moved from its current storage group to the specified storage group. This clause only applies to automatic storage table spaces unless specified with the MANAGED BY AUTOMATIC STORAGE clause (SQLSTATE 42858).

For automatic storage table spaces, an implicit REBALANCE is started at commit time. For a database managed table space being converted to automatic storage managed, an explicit REBALANCE statement is required.

In a partitioned database environment, to alter the storage group association of a table space, the table space must be defined using automatic storage on all database partitions. If the table space on any database partition is not defined using automatic storage, this command will fail unless specified with the MANAGED BY AUTOMATIC STORAGE clause (SQLSTATE 42858). However, it is not required that a table space have the same storage group association on all database partitions for this command to succeed in moving the table space on all database partitions.

storagegroup-name
Identifies the storage group in which table space data will be stored. storagegroup-name must identify a storage group that exists at the current server (SQLSTATE 42704). This is a one-part name.
DATA TAG integer-constant, DATA TAG INHERIT or DATA TAG NONE
Specifies a tag for the data in the table space. This value can be used as part of a WLM configuration in a work class definition or referenced within a threshold definition; for more information refer to the CREATE WORK CLASS SET, ALTER WORK CLASS SET, CREATE THRESHOLD, and ALTER THRESHOLD statements. This clause cannot be specified for USER or SYSTEM TEMPORARY table spaces or for the catalog table space (SQLSTATE 42858).
integer-constant
Valid values for integer-constant are integers from 1 to 9. If an integer-constant is specified and there is an associated storage group, the data tag specified for the table space will override any data tag value specified for the associated storage group.
INHERIT
If INHERIT is specified, the table space must be defined using automatic storage and the DATA TAG is dynamically inherited from the storage group. INHERIT cannot be specified if the table space is not defined using automatic storage (SQLSTATE 42858).
NONE
If NONE is specified, there is no data tag.
MANAGED BY AUTOMATIC STORAGE
Enables automatic storage for a database managed (DMS) table space. Once automatic storage is enabled, no further container operations can be executed on the table space. The table space being converted cannot be using RAW (DEVICE) containers.

If the USING STOGROUP clause is not included when converting from a DMS table space to an automatic storage table space then the default storage group is specified.

Rules

Notes

Examples