在DB2中建立表空间得指向该表空间所属缓冲池,否则表空间指向默认缓冲池
1.缓冲池
1.1 创建缓冲池
语法:CREATE BUFFERPOOL <bp_name> SIZE <number_of_pages> PAGESIZE <integer K>
实例:CREATE BUFFERPOOL OLIVER_BUFFER IMMEDIATE SIZE 250 PAGESIZE 32 K ;
1.2 修改缓冲池的大小
ALTER BUFFERPOOL <bp_name> SIZE <number_of_pages>
1.3 查看当前数据库所有缓冲池
SELECT BPNAME,NPAGES,PAGESIZE FROM SYSCAT.BUFFERPOOLS
2.表空间
2.1 创建表空间
CREATE TABLESPACE TABLESAPCE_NAME PAGESIZE 32K MANAGED BY SYSTEM USING ('E:\DB2\TABLESAPCES') BUFFERPOOL OLIVER_BUFFER
2.2 查看当前数据库所有表空间
SELECT * FROM syscat.tablespaces
2.3 查看表空间使用率
SELECT substr(tbsp_name,1,20) as TABLESPACE_NAME, substr(tbsp_content_type,1,10) as TABLESPACE_TYPE, sum(tbsp_total_size_kb)/1024 as TOTAL_MB, sum(tbsp_used_size_kb)/1024 as USED_MB, sum(tbsp_free_size_kb)/1024 as FREE_MB, tbsp_page_size AS PAGE_SIZE, TBSP_UTILIZATION_PERCENT as percent FROM SYSIBMADM.TBSP_UTILIZATION GROUP BY tbsp_name, tbsp_content_type, tbsp_page_size, TBSP_UTILIZATION_PERCENT ORDER BY TBSP_UTILIZATION_PERCENT;