DB2数据库的创建流程
1.设置db2兼容性(Oracle)
db2set DB2_COMPATIBILITY_VECTOR=ORA(必须在建库之前跑)
2.创建DB2数据库
db2 create db TESTDB
3.连接db2,对db2进行命令操作
db2 connect to TESTDB
一般需要对数据库进行自解锁表操作:db2 update db cfg using AUTO_REORG ON
4.create EEBP
CREATE BUFFERPOOL EEBP IMMEDIATE ALL DBPARTITIONNUMS SIZE 1000 AUTOMATIC PAGESIZE 32768;
PAGESIZE可以根据服务器配置调整大小。
5.create TABLESPACE
CREATE REGULAR TABLESPACE EXIMMETA PAGESIZE 32 K MANAGED BY AUTOMATIC STORAGE EXTENTSIZE 16 OVERHEAD 10.5 PREFETCHSIZE 16 TRANSFERRATE 0.14 BUFFERPOOL EEBP DROPPED TABLE RECOVERY ON;
6.create SCHEMA
CREATE SCHEMA EXIMMETA AUTHORIZATION ROOT;
7.GRANT ROLE TO USER
GRANT DBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT,SECADM ON DATABASE TO USER EXIMMETA;(创建用户EXIMMETA,并赋予EXIMMETA db2权限)
GRANT CREATEIN,DROPIN,ALTERIN ON SCHEMA EXIMMETA TO USER EXIMMETA;(赋予EXIMMETA对于EXIMMETA schema增删改权限)
GRANT USE OF TABLESPACE EXIMMETA TO USER EXIMMETA;
GRANT USE OF TABLESPACE USERSPACE1 TO USER EXIMMETA WITH GRANT OPTION;
总结
到这里,TEATDB中就存在基本的EXIMMETA schema,然后只需要import 对应schema的表结构和数据,就能使用EXIMMETA用户对db2进行操作了