只问耕耘
分类:
2007-08-20 11:22:48
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).
The privileges held by the authorization ID of the statement must include SYSCTRL or SYSADM authority.
.-REGULAR---------------.
>>-CREATE--+-----------------------+---------------------------->
+-LARGE-----------------+
| .-SYSTEM-. |
'-+--------+--TEMPORARY-'
'-USER---'
>--TABLESPACE--tablespace-name---------------------------------->
>--+-----------------------------------------------------------+-->
| .-DATABASE PARTITION GROUP-. |
'-IN--+--------------------------+--db-partition-group-name-'
>--+--------------------------+--------------------------------->
'-9 PAGESIZE--9 integer--+---+-'
'-9 K-'
.-9 MANAGED BY--9 AUTOMATIC STORAGE--9 | size-attributes |---------------------.
>--+------------------------------------------------------------------------+-->
'-MANAGED BY--+-SYSTEM--| system-containers |--------------------------+-'
'-DATABASE--| database-containers |--9 | size-attributes |-'
>--+---------------------------------+-------------------------->
'-EXTENTSIZE--+-number-of-pages-+-'
'-integer--+-K-+--'
'-M-'
>--+-----------------------------------+------------------------>
'-PREFETCHSIZE--+-number-of-pages-+-'
'-integer--+-K-+--'
+-M-+
'-G-'
>--+-----------------------------+------------------------------>
'-BUFFERPOOL--bufferpool-name-'
.-7 OVERHEAD--7 12.67------------------.
>--+----------------------------------+------------------------->
'-OVERHEAD--number-of-milliseconds-'
.-7 FILE SYSTEM CACHING----.
>--+------------------------+----------------------------------->
'-7 NO FILE SYSTEM CACHING-'
.-7 TRANSFERRATE--7 0.18-------------------.
>--+--------------------------------------+--------------------->
'-TRANSFERRATE--number-of-milliseconds-'
>--+---------------------------------+-------------------------><
'-DROPPED TABLE RECOVERY--+-ON--+-'
'-OFF-'
size-attributes:
|--+---------------------+--+-----------------------------+----->
'-9 AUTORESIZE--+-9 NO--+-' '-9 INITIALSIZE--9 integer--+-9 K-+-'
'-9 YES-' +-9 M-+
'-9 G-'
>--+------------------------------------+----------------------->
'-9 INCREASESIZE--9 integer--+-9 PERCENT-+-'
'-+-9 K-+---'
+-9 M-+
'-9 G-'
>--+-----------------------------+------------------------------|
'-9 MAXSIZE--+-9 integer--+-9 K-+-+-'
| +-9 M-+ |
| '-9 G-' |
'-9 NONE-----------'
system-containers:
.----------------------------------------------------------------------.
| .-,------------------. |
V V | |
|----USING--(----'container-string'-+--)--+-----------------------------+-+--|
'-| on-db-partitions-clause |-'
database-containers:
.--------------------------------------------------------------.
V |
|----USING--| container-clause |--+-----------------------------+-+--|
'-| on-db-partitions-clause |-'
container-clause:
.-,---------------------------------------------------.
V |
|--(----+-FILE---+--'container-string'--+-number-of-pages-+-+--)--|
'-DEVICE-' '-integer--+-K-+--'
+-M-+
'-G-'
on-db-partitions-clause:
|--ON--+-DBPARTITIONNUM--+-------------------------------------->
'-DBPARTITIONNUMS-'
.-,--------------------------------------------------.
V |
>--(----db-partition-number1--+--------------------------+-+--)--|
'-TO--db-partition-number2-'
If the database partition group is not specified, the default database partition group (IBMDEFAULTGROUP) is used for REGULAR, LARGE, and USER TEMPORARY table spaces. For SYSTEM TEMPORARY table spaces, the default database partition group IBMTEMPGROUP is used.
The default value is provided by the pagesize 9 database configuration parameter, which is set when the database is 9 created.
An automatic storage table space is created as either a system 9 managed space (SMS) table space or a database managed space (DMS) 9 table space. 9 With an automatic storage table space, the database manager 9 determines which containers are to be assigned to the table space, 9 based upon the storage paths that are associated with the database.
9Each container-string can be an absolute or relative directory name. The directory name, if not absolute, is relative to the database directory. If any component of the directory name does not exist, it is created by the database manager. When a table space is dropped, all components created by the database manager are deleted. If the directory identified by container-string exist, it must not contain any files or subdirectories (SQLSTATE 428B2).
The format of container-string is dependent on the operating system. The containers are specified in the normal manner for the operating system. For example, a Windows directory path begins with a drive letter and a ":", while on UNIX-based systems, a path begins with a "/".
3 Remote resources (such as LAN-redirected drives 3 or NFS-mounted file systems) are currently only supported when using 3 Network Appliance Filers, IBM iSCSI, IBM Network Attached Storage, 3 Network Appliance iSCSI, NEC iStorage S2100, S2200, or S4100, 3 7 or NEC Storage NS Series with a Windows DB2 server. 7 Note that NEC Storage NS Series is only supported with the use of an 7 uninterrupted power supply (UPS); continuous UPS (rather than 7 standby) is recommended.3 .
For a FILE container, the container-string must be an absolute or relative file name. The file name, if not absolute, is relative to the database directory. If any component of the directory name does not exist, it is created by the database manager. If the file does not exist, it will be created and initialized to the specified size by the database manager. When a table space is dropped, all components created by the database manager are deleted.
For a DEVICE container, the container-string must be a device name. The device must already exist.
All containers must be unique across all databases; a container can belong to only one table space. The size of the containers can differ, however optimal performance is achieved when all containers are the same size. The exact format of container-string is dependent on the operating system. The containers will be specified in the normal manner for the operating system.
3 Remote resources (such as LAN-redirected drives 3 or NFS-mounted file systems) are currently only supported when using 3 Network Appliance Filers, IBM iSCSI, IBM Network Attached Storage, 3 Network Appliance iSCSI, NEC iStorage S2100, S2200, or S4100, 3 7 or NEC Storage NS Series with a Windows DB2 server. 7 Note that NEC Storage NS Series is only supported with the use of an 7 uninterrupted power supply (UPS); continuous UPS (rather than 7 standby) is recommended.3 .
The partition specified by number and every partition in the range of partitions must exist in the database partition group on which the table space is defined (SQLSTATE 42729). A partition-number may only appear explicitly or within a range in exactly one on-db-partitions-clause for the statement (SQLSTATE 42613).
The default value is provided by the DFT_EXTENT_SZ |database configuration parameter, which has a valid range of 2-256 |pages.
|The default value is provided by the DFT_PREFETCH_SZ configuration parameter.
You use the argument " $N" ([blank]$N) to indicate a database partition expression. A database partition expression can be used anywhere in the container name, and multiple database partition expressions can be specified. Terminate the database partition expression with a space character; whatever follows the space is appended to the container name after the database partition expression is evaluated. If there is no space character in the container name after the database partition expression, it is assumed that the rest of the string is part of the expression. The argument can only be used in one of the following forms:
Syntax | Example | Value |
---|---|---|
[blank]$N | " $N" | 5 |
[blank]$N+[number] | " $N+1011" | 1016 |
[blank]$N%[number] | " $N%3" a | 2 |
[blank]$N+[number]%[number] | " $N+12%13" | 4 |
[blank]$N%[number]+[number] | " $N%3+20" | 22 |
a % is modulus. |
For example:
CREATE TABLESPACE TS1 MANAGED BY DATABASE USING
(device '/dev/rcont $N' 20000)
On a two database partition system, the following containers
would be created:
/dev/rcont0 - on DATABASE PARTITION 0
/dev/rcont1 - on DATABASE PARTITION 1
CREATE TABLESPACE TS2 MANAGED BY DATABASE USING
(file '/DB2/containers/TS2/container $N+100' 10000)
On a four database partition system, the following containers
would be created:
/DB2/containers/TS2/container100 - on DATABASE PARTITION 0
/DB2/containers/TS2/container101 - on DATABASE PARTITION 1
/DB2/containers/TS2/container102 - on DATABASE PARTITION 2
/DB2/containers/TS2/container103 - on DATABASE PARTITION 3
CREATE TABLESPACE TS3 MANAGED BY SYSTEM USING
('/TS3/cont $N%2','/TS3/cont $N%2+2')
On a two database partition system, the following containers
would be created:
/TS3/cont0 - On DATABASE PARTITION 0
/TS3/cont2 - On DATABASE PARTITION 0
/TS3/cont1 - On DATABASE PARTITION 1
/TS3/cont3 - On DATABASE PARTITION 1
If database partition = 5, the containers:
'/dbdir/node $N /cont1'
'/ $N+1000 /file1'
' $N%10 /container'
'/dir/ $N%5+2000 /dmscont'
are created as:
'/dbdir/node5/cont1'
'/1005/file1'
'5/container'
'/dir/2000/dmscont'
Example 1: Create a regular DMS table space on a UNIX-based system using 3 devices of 10 000 4K pages each. Specify their I/O characteristics.
CREATE TABLESPACE PAYROLL
MANAGED BY DATABASE
USING (DEVICE'/dev/rhdisk6' 10000,
DEVICE '/dev/rhdisk7' 10000,
DEVICE '/dev/rhdisk8' 10000)
OVERHEAD 12.67
TRANSFERRATE 0.18
Example 2: Create a regular SMS table space on Windows NT or Windows 2000 using 3 directories on three separate drives, with a 64-page extent size, and a 32-page prefetch size.
CREATE TABLESPACE ACCOUNTING
MANAGED BY SYSTEM
USING ('d:\acc_tbsp', 'e:\acc_tbsp', 'f:\acc_tbsp')
EXTENTSIZE 64
PREFETCHSIZE 32
Example 3: Create a temporary DMS table space on a UNIX-based system using 2 files of 50 000 pages each, and a 256-page extent size.
CREATE TEMPORARY TABLESPACE TEMPSPACE2
MANAGED BY DATABASE
USING (FILE '/tmp/tempspace2.f1' 50000,
FILE '/tmp/tempspace2.f2' 50000)
EXTENTSIZE 256
Example 4: Create a DMS table space in database partition group ODDNODEGROUP (partitions 1,3, and 5) on a UNIX-based system. Use the device /dev/rhdisk0 for 10 000 4K pages on each partition. Specify a partition-specific device with 40 000 4K pages for each partition.
CREATE TABLESPACE PLANS
MANAGED BY DATABASE
USING (DEVICE '/dev/rhdisk0' 10000, DEVICE '/dev/rn1hd01' 40000)
ON DBPARTITIONNUM (1)
USING (DEVICE '/dev/rhdisk0' 10000, DEVICE '/dev/rn3hd03' 40000)
ON DBPARTITIONNUM (3)
USING (DEVICE '/dev/rhdisk0' 10000, DEVICE '/dev/rn5hd05' 40000)
ON DBPARTITIONNUM (5)
9 Example 5: Create a regular 9 automatic storage table space named DATATS, allowing the system to 9 make all decisions with respect to table space size and growth. 9
9 CREATE TABLESPACE DATATS
9 or 9
9CREATE TABLESPACE DATATS
9 MANAGED BY AUTOMATIC STORAGE
9 Example 6: Create a temporary 9 automatic storage table space named MYTEMP. 9
9 CREATE TEMPORARY TABLESPACE MYTEMP
9 or 9
9CREATE TEMPORARY TABLESPACE MYTEMP
9 MANAGED BY AUTOMATIC STORAGE
9 Example 7: Create a regular 9 automatic storage table space named USERSPACE3 with an initial size 9 of 100 megabytes and a maximum size of 1 gigabyte. 9
9CREATE TABLESPACE USERSPACE3
9 INITIALSIZE 100 M
9 MAXSIZE 1 G
9 Example 8: Create a large 9 automatic storage table space named LARGEDATA with a growth rate of 9 10 percent (that is, its total size increases by 10 percent each 9 time that it is automatically resized) and a maximum size of 512 9 megabytes. 9 Instead of specifying the INITIALSIZE clause, let the database 9 manager determine an appropriate initial size for the table space. 9
9CREATE LARGE TABLESPACE LARGEDATA
9 INCREASESIZE 10 PERCENT
9 MAXSIZE 512 M
9 Example 9: Create a regular 9 DMS table space named USERSPACE4 with two file containers (each 9 container being 1 megabyte in size), a growth rate of 2 megabytes, 9 and a maximum size of 100 megabytes. 9
9CREATE TABLESPACE USERSPACE4
9 MANAGED BY DATABASE USING (FILE '/db2/file1' 1 M, FILE '/db2/file2' 1 M)
9 AUTORESIZE ON
9 INCREASESIZE 2 M
9 MAXSIZE 100 M
This topic can be found in: SQL Reference, Volume 2.