日期:2014-05-16  浏览次数:20520 次

DB2创建表空间
windows下面创建的完整过程
db2set db2codepage=819
db2 create database test03
db2 connect to test03 user db2amdin using 1
db2 CREATE Bufferpool USER8 SIZE 100000 PAGESIZE 8K
db2 CREATE Bufferpool USER16 SIZE 1000 PAGESIZE 16 K
db2 CREATE Bufferpool USER32 SIZE 1000 PAGESIZE 32 K
db2stop force
db2start
db2 connect to test03 user easymis using easymis
db2 "CREATE REGULAR TABLESPACE TS_USER8 PAGESIZE 8K MANAGED BY SYSTEM USING ('FSMS_8K_1') BUFFERPOOL USER8"
db2 "CREATE REGULAR TABLESPACE TS_USER16 PAGESIZE 16K MANAGED BY SYSTEM USING ('FSMS_16K_1') BUFFERPOOL USER16"
db2 "CREATE REGULAR TABLESPACE TS_USER32 PAGESIZE 32K MANAGED BY SYSTEM USING ('FSMS_32K_1') BUFFERPOOL USER32"
db2 GRANT   DBADM,CREATETAB,BINDADD,CONNECT ON DATABASE   TO USER EASYMIS
db2 GRANT   DBADM,CREATETAB,BINDADD,CONNECT,LOAD ON DATABASE   TO USER EASYMIS
db2 connect to test03 user easymis using easymis
db2 -f dbstruct.sql >kk.log


用配置助手增加odbc和cli的命令,并且将用户密码配置进去
用odbctool将数据一次性加载到数据库中。
配置jdbc连接
直接使用jcc方式能够使用。
     <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
     <property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
     <property name="connection.username">easymis</property>
     <property name="connection.password">1</property>
     <property name="connection.url">jdbc:db2://192.168.20.249:50000/test03</property>

如果采用app方式,需要将db2java.zip修改成db2java.jar
db2jdbcbind -url jdbc:db2://192.168.20.249:50000/test03 -user easymis -password 1
     <property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>
     <property name="connection.driver_class">COM.ibm.db2.jdbc.app.DB2Driver</property>
     <property name="connection.username">easymis</property>
     <property name="connection.password">1</property>
     <property name="connection.url">jdbc:db2:test03</property>

--------------------------------------------------
三、aix下面创建过程
aix下面创建完整的过程
db2set db2codepage=819
db2 create database easytest on /home/db2inst1
db2 connect to test04 user db2inst1 using db2
db2 CREATE Bufferpool USER8 SIZE 100000 PAGESIZE 8K
db2 CREATE Bufferpool USER16 SIZE 1000 PAGESIZE 16 K
db2 CREATE Bufferpool USER32 SIZE 1000 PAGESIZE 32 K
db2stop force
db2start
db2 connect to test04 user db2inst1 using db2
db2 "CREATE REGULAR TABLESPACE TS_USER8 PAGESIZE 8K MANAGED BY SYSTEM USING ('FSMS_8K_1') BUFFERPOOL USER8"
db2 "CREATE REGULAR TABLESPACE TS_USER16 PAGESIZE 16K MANAGED BY SYSTEM USING ('FSMS_16K_1') BUFFERPOOL USER16"
db2 "CREATE REGULAR TABLESPACE TS_USER32 PAGESIZE 32K MANAGED BY SYSTEM USING ('FSMS_32K_1') BUFFERPOOL USER32"
db2 CREATE Bufferpool TMPBUF8 SIZE 10000 PAGESIZE 8K
db2 "CREATE   TEMPORARY   TABLESPACE TempTS_USER8 PAGESIZE 8K   MANAGED BY SYSTEM   USING ('/home/db2inst1/db2inst1/TEMPNODE0004'   )   EXTENTSIZE 16 OVERHEAD 10.5 PREFETCHSIZE 16 TRANSFERRATE 0.14 BUFFERPOOL "TMPBUF8" DROPPED TABLE RECOVERY OFF"
db2 GRANT   DBADM,CREATETAB,BINDADD,CONNECT,LOAD ON DATABASE   TO USER EASYMIS
db2 GRANT USE OF TABLESPACE TS_USER8 TO easymis
db2 GRANT USE OF TABLESPACE TS_USER16 TO easymis
db2 GRANT USE OF TABLESPACE TS_USER32 TO easymis
db2 connect to test04 user easymis using easymis
db2 -f dbstruct.sql >kk.log


设置堆空间大小
DB2   UPDATE