db2手工創建表空間
db2 v10.1
1.1 創建系統管理使用文件目錄的表空間
db2 "create tablespace newtbs01 managed by system using ('/home/db2inst3/test/newtb/newtbs01')"
1.2 創建數據庫管理的使用文件的表空間
db2 "create tablespace newtbs02 managed by database using (file '/home/db2inst3/test/newtb/newtbs02.file' 1000)"
7.9M newtbs02.file
1.3 創建數據庫管理的使用多文件的表空間
db2 "create tablespace newtbs03 managed by database using (file '/home/db2inst3/test/newtb/newtbs031.file' 4000,
file '/home/db2inst3/test/newtb/newtbs032.file' 2000)"
32M newtbs031.file
16M newtbs032.file
1.4 創建系統管理的pagesize是16k的表空間
$ db2 "create tablespace newtbs04 pagesize 16 k managed by system using ('/home/db2inst3/test/newtb/newtbs04')"
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL1582N The PAGESIZE of the table space "NEWTBS04" does not match the
PAGESIZE of the bufferpool "IBMDEFAULTBP" associated with the table space.
SQLSTATE=428CB
發現報錯,根據提示,新建的16k的表空間和默認使用的buffer IBMDEFAULTBP不匹配
創建的數據庫是8k的pagesize,而這里我們要創建16k的表空空間
在db2中表空間需要對應pagesize的buffer pool
查看下當前bufferpool情況
$ db2 "select char(BPNAME,20),substr(NPAGES,1,10),substr(PAGESIZE,1,10) from syscat.bufferpools"
1 2 3
-------------------- ---------- ----------
IBMDEFAULTBP -2 8192
1 record(s) selected.
新建一個16k的bufferpool
$ db2 "create bufferpool bp_16k size 10000 pagesize 16K"
DB20000I The SQL command completed successfully.
$ db2 "select char(BPNAME,20),substr(NPAGES,1,10),
substr(PAGESIZE,1,10) from syscat.bufferpools"
1 2 3
-------------------- ---------- ----------
IBMDEFAULTBP -2 8192
BP_16K 10000 16384
2 record(s) selected.
1.5 創建了一個16k的buffer pool,再來使用這個16k的buffer pool創建一個16k的表空間
$ db2 "create tablespace newtbs04 pagesize 16 k managed by system using ('/home/db2inst3/test/newtb/newtbs04') bufferpool bp_16k"
DB20000I The SQL command completed successfully.
使用db2pd -d testdb -tablespace查看剛才新建的4個表空間:
使用UNIX中的設備創建表空間(就不做實驗了)
看db2信息中心說明
Example : Creating DMS table spaces on AIX
The following SQL statement creates a DMS table space on an AIX system
using three logical volumes of 10 000 pages each, and specifies their I/O characteristics:
CREATE TABLESPACE RESOURCE
MANAGED BY DATABASE
USING (DEVICE '/dev/rdblv6' 10000,
DEVICE '/dev/rdblv7' 10000,
DEVICE '/dev/rdblv8' 10000)
OVERHEAD 7.5
TRANSFERRATE 0.06
