1.为db数据文件创建空间
mkdir -p /data//db2dir/testdb/
2.赋予db2用户权限chown -R db2inst1 /data/db2dir/testdb
3.建库(需要相应的权限) 创建数据库
create database testdb
on /data/db2dir/testdb
using codeset GBK territory CN
collate using identity
连接到数据库db2 connect to testdb创建缓冲池
create bufferpool dw_bp immediate size 3000 pagesize 16k
创建DMS表空间
create tablespace dw_tbl pagesize 16384 managed by database using (file '/data/db2dir/testdb/NODE00001' 500000) extentsize 16 prefetchsize 16 bufferpool dw_bp
create tablespace dw_idx pagesize 16384
managed by database using (file '/data/db2dir/testdb/NODE00002' 190000) extentsize 16 prefetchsize 16 bufferpool dw_bp
创建用户临时表空间
create user temporary tablespace TEMPSP16K pagesize 16384 managed by database using(file '/data/db2dir/testdb/NODE00003' 65000) extentsize 16 prefetchsize 16 bufferpool dw_bp
4.设置db相关参数(根据需要)
update db cfg for testdb using newlogpath /data/db2dir/dccdb/log.01
update db cfg for testdb using
logprimary 20
update db cfg for testdb using
logfilsiz 7680
update db cfg using STMTHEAP 16384
update db cfg using APPLHEAPSZ 512
5.创建模式
create schema db2test [authorization db2test]