./install建立實例:
groupadd database useradd prod -g database useradd prodfenc -g database cd /opt/ibm/db2/V9.7/instance ./db2icrt -a server -u prodfenc prod配置實例參數:
cd ~prod vi .bashrc #在最後加入 ./sqllib/db2profile設置實例在每次登陸時自啓動
su prod db2iauto -on prod啓動實例
建立/查看/鏈接數據庫 sql
db2 create database LEON db2 list database directory db2 connect to LEON查看錶空間(明細)
db2 list tablespaces show detail建立一個8k頁面大寫的緩衝池
db2 "CREATE BUFFERPOOL LEON_BU_8K IMMEDIATE SIZE 2000 PAGESIZE 8k" db2 drop bufferpool LEON_BU_8K db2 create bufferpool leon_bp_8k immediate size 5000 pagesize 8k建立表空間(8K頁面大小)
mkdir -p /database chown -R prod:database database db2 "create tablespace LEONSPACE0 pagesize 8192 managed by database using (FILE'/database/container1' 5000 ) bufferpool leon_bp_8k"
#只能建立到/databse,container目錄由數據庫本身建立;若是用戶建立的話,那麼在建立表空間時會報如下錯誤 DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0298N Bad container path. SQLSTATE=428B2