This part portrays the Database Storagegroups.
Introduction
A lot of Storage ways to store database table or articles, is a capacity gathering. You can allot the tablespaces to the capacity gathering. At the point when you make a database, all the tablespaces take default storagegorup. The default stockpiling bunch for a database is 'IBMSTOGROUP'. At the point when you make another database, the default stockpiling bunch is dynamic, in the event that you pass the "Programmed STOGROUP NO" parameter toward the finish of "Make DATABASE" order. The database doesn't have any default stockpiling gatherings.
Listing storagegroups
You can list all the storagegroups in the database.
Syntax: [To see the list of available storagegroups in current database]
db2 select * from syscat.stogroups
Example: [To see the list of available storagegorups in current database]
db2 select * from syscat.stogroups
Creating a storagegroup
Here is a linguistic structure to make a storagegroup in the database:
Syntax: [To create a new stogroup. The ‘stogropu_name’ indicates name of new storage group and ‘path’ indicates the location where data (tables) are stored]
db2 create stogroup on ‘path’
Example: [To create a new stogroup ‘stg1’ on the path ‘data1’ folder]
db2 create stogroup stg1 on ‘/data1’
Output:
DB20000I The SQL command completed succesfully
Creating tablespace with stogroup
Here is the manner by which you can make a tablespace with storegroup:
Syntax: [To create a new tablespace using existed storage group]
db2 create tablespace <tablespace_name> using stogroup <stogroup_name>
Example: [To create a new tablespace named ‘ts1’ using existed storage group ‘stg1’]
db2 create tablespace ts1 using stogroup stg1
Output:
DB20000I The SQL command completed succesfully
Altering a storagegroup
You can adjust the area of a storegroup by utilizing following linguistic structure:
Syntax: [To shift a storage group from old location to new location]
db2 alter stogroup add ‘location’, ‘location’
Example: [To modify location path from old location to new location for storage group named ‘sg1’]
db2 alter stogroup sg1 add ‘/path/data3’, ‘/path/data4’
Dropping folder path of storagegroup
Before dropping organizer way of storagegroup, you can include new area for the storagegroup by utilizing change order.
Syntax: [To drop old path from storage group location]
db2 alter stogroup drop ‘/path’
Example: [To drop storage group location from ‘stg1’]
db2 alter stogroup stg1 drop ‘/path/data1’
Rebalancing a tablespace
Rebalancing the tablespace is required when we make another envelope for storagegroup or tablespaces while the exchanges are led on the database and the tablespace turns out to be full. Rebalancing refreshes database setup records with new storagegroup.
Syntax: [To rebalance the tablespace from old storage group path to new storage group]
db2 alter tablspace <ts_name> rebalance
Example: [To rebalance]
db2 alter tablespace ts1 rebalance
Renaming a storagegroup
Syntax: [To modify the name of existing storage name]
db2 rename stogroup <old_stg_name> to <new_stg_name>
Example: [To modify the name of storage group from ‘sg1’ to new name ‘sgroup1’]
db2 rename stogroup sg1 to sgroup1
Dropping a storage group
Step 1: Before dropping any storagegroup, you can assign some different storagegroup for tablespaces.
Syntax: [To assign another storagegroup for table space.]
db2 alter tablspace <ts_name> using stogroup <another sto_group_name>
Example: [To change from one old stogroup to new stogroup named ‘sg2’ for tablespace ‘ts1’]
db2 alter tablespace ts1 using stogroup sg2
Step 2:
Syntax: [To drop the existing stogroup]
db2 drop stogorup <stogroup_name>
Example: [To drop stogroup ‘stg1’ from database]
db2 drop stogroup stg1
