標籤:des blog http 使用 ar strong 檔案 資料 art
一、建資料表空間和資料庫
1.在db2ad、db2db和db2ap上均執行:
[sql] view plaincopyprint?
- db2set db2comm=tcpip
- db2set db2codepage=1386
db2set db2comm=tcpip
db2set db2codepage=1386
2.建立資料庫:
[sql] view plaincopyprint?
- db2 create db <dbname> using codeset gbk territory CN collate using identity
db2 create db <dbname> using codeset gbk territory CN collate using identity
3.串連上資料庫:
[sql] view plaincopyprint?
- db2 "connect to <dbname>"
db2 "connect to <dbname>"
4.建立緩衝池 + 建立資料表空間;
1).刪除舊的資料表空間:
[sql] view plaincopyprint?
- db2 drop tablespace tablespace1, tablespace2, tablespace3
db2 droptablespace tablespace1, tablespace2,tablespace3
2).建立緩衝池:
[sql] view plaincopyprint?
- db2 create bufferpool bp32k all nodes size -1 pagesize 32k
db2 createbufferpool bp32k all nodes size -1 pagesize 32k
bp32k為該緩衝池的名稱;
32K為頁大小;
size=-1表示使用預設的buffpage,而buffpage可以通過db2 get db cfg|grep -i buff參數查看到;
3).建立資料表空間:
[sql] view plaincopyprint?
- db2 "create regular tablespace tablespace1 pagesize 32k managed by database using(file ‘/usr/yixiayizi/tablespace1‘ 5g) bufferpool bp32k"
- db2 "create regular tablespace tablespace2 pagesize 32k managed by database using(file ‘/usr/yixiayizi/tablespace2‘ 10g) bufferpool bp32k"
- db2 "create regular tablespace tablespace3 pagesize 32k managed by database using(file ‘/usr/yixiayizi/tablespace3‘ 2g) bufferpool bp32k"
db2 "createregular tablespace tablespace1 pagesize32k managed by database using(file ‘/usr/yixiayizi/tablespace1‘ 5g) bufferpoolbp32k"
db2 "createregular tablespace tablespace2 pagesize32k managed by database using(file ‘/usr/yixiayizi/tablespace2‘ 10g) bufferpoolbp32k"
db2 "createregular tablespace tablespace3 pagesize32k managed by database using(file ‘/usr/yixiayizi/tablespace3‘ 2g) bufferpoolbp32k"
注意(file ‘/usr/yixiayizi/tablespace1‘ 5g)的設定:
第一個參數:
當指向外置盤時,file改為device;
當指向檔案路徑時,為file;
第二個參數:需要是絕對路徑;
第三個參數:該資料表空間的大小;
db2建立資料庫