[DB2 database tablespace daily management commands]

1. Create a bufferpool with a pagesize of 32kb
create bufferpool bp32k size 2000 pagessize 32k


2. View the bufferpool attribute
select * from syscat.bufferpools


3. Change the buffer pool size
alter bufferpool bp32k size 10

-- view the system buffer pool
select * from syscat.bufferpools
alter bufferpool IBMDEFAULTBP size 4000
alter bufferpool BUF_HGQW size 40


4. Create a data page as a 32kb data block as a 1024kb prefetch value is the default, Create large tablespace tbs_data
pagesize 32k managed by database using (file '/database/tbs_data/cont0' 100M,file '/database/tbs_data/cont1' 100M) extentsize 32 prefetchsize automatic bufferpool bp32k no file system caching

5. Create an SMS system temporary tablespace with a data page of 32kb
create temporary tablespace tbs_temp pagesize 32k managed by system using ('/database/tbs_temp') bufferpool bp32k

6. Create an SMS user temporary tablespace with a data page of 32kb
create user temporary tablespace tbs_user_temp pagesize 32k managed by system using('/database/tbs_usertemp') bufferpool bp32k


7. Create an automatic storage management tablespace with a data page of 32kb
create tablespace tbs_index pagesize 32k bufferpool bp32k

8. Create an automatic storage management tablespace with an initial size of 100MB, an increment of 100MB, and a maximum size of 100GB
create tablespace tbs_data2 initialsize 100M increasesize 100M maxsize 100G


9. View tablespace information
list tablespaces
list tablespaces show detail
db2pd -d testdb -tablespaces
get snapshot for tablespaces on testdb
You can also view the two views sysibmadm.snaptbsp and sysibmadm.snapcontainer


10. View tablespace related container information
list tablespace containers for 7 #tablespace id
list tablespace containers for 7 show detail


11. Allocate space

If there is still unallocated space in the storage corresponding to the DMS tablespace, you can extend the size of the existing tablespace container through the extend, reduce, or resize options of the alter tablespace. Among them, extend is used to expand the container size, reduce is used to reduce the existing container size, and resize resets the container size. For reduce and resize, make sure that the changed tablespace has enough space, otherwise DB2 will reject the operation.
alter tablespace tbs_data extend (file '/database/tbs_data/cont0' 10M)


12. Increase the container

If the table space container has no remaining space, you can add the container through the add option. Of course, you can also delete the container through the drop option if necessary. For add and drop operations, data rebalance occurs between containers. If the amount of data is large, the rebalance time may take a long time, which may have a great impact on the system.
alter tablespace tbs_data add(file '/database/tbs_data/cont2' 100m)


13. Data offset

If the begin new strip set option is used, a new container will be used when the existing container space runs out. This option will prevent data from being rebalanced between containers, but will cause data offset.
alter tablespace tbs_data begin new stripe set (file '/database/tbs_data/cont3' 100m)

14. View automatic storage management tablespace paths
db2pd -d testdb -storagepaths


15. For the automatic storage management tablespace, container changes cannot be made at the tablespace level, but only at the data level, because the automatic storage path is specified when the database is built. A new storage path for the database can be added using the add storage on option. Before v9.7, the automatic storage path can only be added, not deleted. The newly added storage path will not be used immediately by the table space. The newly added path will be used only when the file system space of the existing storage path is full. The added path is only to solve the capacity problem. After v9.7, as long as rebalance is performed on a tablespace that uses automatic storage management, the tablespace can immediately use the new storage path.

alter database testdb add storage on '/database/ czm ' alter
tablespace


7 rebalance The tname column is null and not null alter table test alter tname drop not null alter table test alter tname set not NULL alter table staff drop column years alter table staff alter job set data type varchar (20)










Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042825&siteId=291194637
Recommended