DB2 Version 9.7 for Linux, UNIX, and Windows

ALTER DATABASE statement

The ALTER DATABASE statement adds new storage paths to, or removes existing storage paths from, the collection of paths that are used for automatic storage table spaces. An automatic storage table space is a table space that has been created using automatic storage; that is, the MANAGED BY AUTOMATIC STORAGE clause has been specified on the CREATE TABLESPACE statement, or no MANAGED BY clause has been specified at all. If a database is enabled for automatic storage, container and space management characteristics of its table spaces can be completely determined by the database manager. If the database is not currently enabled for automatic storage then the act of adding storage paths will enable it.

Invocation

The 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 either SYSADM or SYSCTRL authority.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-ALTER DATABASE--+---------------+---------------------------->
                   '-database-name-'   

   .-----------------------------------------------.   
   |                         .-,--------------.    |   
   V  (1)                    V                |    |   
>----------+-ADD STORAGE ON----'storage-path'-+--+-+-----------><
           |                  .-,--------------. |     
           |                  V                | |     
           '-DROP STORAGE ON----'storage-path'-+-'     

Notes:
  1. Each clause can be specified only once.

Description

database-name
An optional value specifying the name of the database that is to be altered. If specified, the value must match the name of the database to which the application is currently connected (not the alias that the client might have cataloged); otherwise, an error is returned (SQLSTATE 42961).
ADD STORAGE ON
Specifies that one or more new storage paths are to be added to the collection of storage paths that are used for automatic storage table spaces.
'storage-path'
A string constant that specifies either an absolute path or the letter name of a drive (Windows operating systems only) on which containers for automatic storage table spaces are to be created.
DROP STORAGE ON
Specifies that one or more storage paths are to be removed from the collection of storage paths that are used for automatic storage table spaces. If table spaces are actively using a storage path being dropped, then the state of the storage path is changed from "In Use" to "Drop Pending" and future use of the storage path will be prevented.
'storage-path'
A string constant that specifies either an absolute path or the letter name of a drive (Windows operating systems only).

Rules

Notes

Examples

Example 1: Add two paths under the /db2 directory (/db2/filesystem1 and /db2/filesystem2) and a third path named /filesystem3 to the space for automatic storage table spaces that is associated with the currently connected database.
   ALTER DATABASE ADD STORAGE ON '/db2/filesystem1', '/db2/filesystem2',
     '/filesystem3'
Example 2: Add drives D and E to the space for automatic storage table spaces that is associated with the SAMPLE database.
   ALTER DATABASE SAMPLE ADD STORAGE ON 'D:', 'E:\'
Example 3: Add directory F:\DB2DATA and drive G to the space for automatic storage table spaces that is associated with the currently connected database.
   ALTER DATABASE ADD STORAGE ON 'F:\DB2DATA', 'G:'
Example 4: Add a storage path that uses a database partition expression to differentiate the storage paths on each of the database partitions.
   ALTER DATABASE ADD STORAGE ON '/dataForPartition $N'
The storage path that would be used on database partition 0 is /dataForPartition0; on database partition 1, it would be /dataForPartition1; and so on.
Example 5: Add storage paths to a database that is not automatic storage enabled, for the purposes of enabling automatic storage for the database.
   CREATE DATABASE MYDB AUTOMATIC STORAGE NO
   CONNECT TO MYDB
   ALTER DATABASE ADD STORAGE ON '/db2/filesystem1', '/db2/filesystem2' 
Database MYDB is now enabled for automatic storage.
Example 6: Remove paths /db2/filesystem1 and /db2/filesystem2 from the currently connected database.
   ALTER DATABASE DROP STORAGE ON '/db2/filesystem1', '/db2/filesystem2'
After the storage is dropped successfully, use the ALTER TABLESPACE statement with the REBALANCE clause for each table space that was using these storage paths to rebalance the table space.
Example 7: A storage path with a database partition expression (/dataForPartition $N) was previously added to the database and now it is to be removed.
   ALTER DATABASE DROP STORAGE ON '/dataForPartition $N'
After the storage is dropped successfully, use the ALTER TABLESPACE statement with the REBALANCE clause for each table space that was using these storage paths to rebalance the table space.