Tablespaces in DB2
Tablespaces in DB2
- Database consists of Tables and Indexes which are logical entities as we don't find any particular files on file system with tabular formatted data.
- Question of how to save the tables and Indexes is solved by Tablespaces.
- Tablespaces can be defined as configuration file which configures
- Page size to be used for the tables with it.(4k,8k,16k AND 32k)
- Type of / Name of Buffer pool to be used while loading data.
- No. of pages to be stored in an container( i.e Extent size)
- No. of pages to be read during prefetch operation (i.e prefetch size)
- Tablespaces are composed of one or more containers which could be a directory or file on file system or an RAW device.
- Multiple tablespaces can share one bufferpool until their page size matches.
- There are four types of tablespaces
- REGULAR
- It is used for storing tables and indexes
- LARGE
- It is used for storing Large object such as CLOB or BLOB. Generally a table is partly saved in REGULAR tablespace and its large object column is configured to be saved in LARGE tablespace
- SYSTEM TEMPORARY
- It is internally used by DB2 for Sorting and joins operations.
- USER TEMPORARY
- It is used for storing User defined Global temporary tables.
- Table spaces can be set up in different ways, depending on how we want to use available storage.
- We can have the OS manage allocations of space, or
- We can have the database manager allocate space for your data, based on parameters you specify. Or
- We can create table spaces that allocate storage automatically.
- The three types of table spaces manager are known as:
- System managed space (SMS), in which the operating system's file manager
controls the storage space once you have defined the location for
storing database files.
- Database managed space (DMS), in which the database manager controls the
usage of storage space one you have allocated storage containers.
- Automatic storage table spaces, in which the database manager controls the creation of containers as needed.
- Both SMS and DMS are deprecated in version 10.1 onwards and many be removed in the future release, where as Automatic storage tablespaces are being used for storing user data.
- Bydefault, while creating tablespace, if non of the options are specified then automatic storage management is used for that particular tablespace.
- Following are some of the ways for creating automatics storage tablespace
- CREATE TABLESPACE TS1
- CREATE TABLESPACE TS2 MANAGED BY AUTOMATIC STORAGE
- CREATE TEMPORARY TABLESPACE TEMPTS
CREATE USER TEMPORARY TABLESPACE USRTMP MANAGED BY AUTOMATIC STORAGE
- CREATE LARGE TABLESPACE LONGTS
- CREATE TABLESPACE TS3 INITIALSIZE 8K INCREASESIZE 20 PERCENT MANAGED BY AUTOMATIC STORAGE
- CREATE TABLESPACE TS4 MAXSIZE 2G
- CREATE TABLESPACE TS5 USING STOGROUP SG_HOT
No comments:
Post a Comment