DB2建库语句

 总结项目中的db2数据库建库语句:


DROP DATABASE MDPDB;
mkdir -p /home/mdpinst/MDPDB
chmod -R 777 /home/mdpinst/MDPDB

-- 创建数据库
CREATE DATABASE MDPDB on /home/mdpinst/datatbs DBPATH ON /home/mdpinst USING CODESET GBK TERRITORY CN;
CONNECT TO MDPDB;

-- 缓冲池
-- 创建业务数据缓冲池
CREATE BUFFERPOOL "BUFF_BUSINESS_TS" SIZE 102400 PAGESIZE 32K;
--创建索引数据缓冲池
CREATE BUFFERPOOL "BUFF_BUSINESS_IX" SIZE 51200 PAGESIZE 32K;

-- 创建系统数据缓冲池
CREATE BUFFERPOOL "BUFF_SYS_TS" SIZE 102400 PAGESIZE 4K;
--创建系统索引数据缓冲池
CREATE BUFFERPOOL "BUFF_SYS_IX" SIZE 51200 PAGESIZE 4K;

CONNECT RESET;
CONNECT TO MDPDB;

-- 创建用户表空间,存放数据
CREATE Large TABLESPACE "MDPUSERSAPCE" PAGESIZE 32K MANAGED BY DATABASE USING 
(File '/home/mdpinst/MDPDB/BUSINESSTP' 40G) 
AUTORESIZE YES INCREASESIZE 10G EXTENTSIZE 32 PREFETCHSIZE 32 BUFFERPOOL "BUFF_BUSINESS_TS";
-- 创建索引表空间,存放索引数据
CREATE Large TABLESPACE "MDPINDEXSAPCE" PAGESIZE 32K MANAGED BY DATABASE USING 
(File '/home/mdpinst/MDPDB/BUSINESSINDEX' 20G) 
AUTORESIZE YES INCREASESIZE 10G EXTENTSIZE 32 PREFETCHSIZE 32 BUFFERPOOL "BUFF_BUSINESS_IX";

-- 创建用户表空间,存放数据
CREATE Large TABLESPACE "TABSYS" PAGESIZE 4K MANAGED BY DATABASE USING 
(File '/home/mdpinst/MDPDB/SYSTP' 10G) 
AUTORESIZE YES INCREASESIZE 10G EXTENTSIZE 32 PREFETCHSIZE 32 BUFFERPOOL "BUFF_SYS_TS";
-- 创建索引表空间,存放索引数据
CREATE Large TABLESPACE "IDXSYS" PAGESIZE 4K MANAGED BY DATABASE USING 
(File '/home/mdpinst/MDPDB/SYSINDEX' 5G) 
AUTORESIZE YES INCREASESIZE 5G EXTENTSIZE 32 PREFETCHSIZE 32 BUFFERPOOL "BUFF_SYS_IX";

-- 创建系统临时表空间
CREATE TEMPORARY TABLESPACE "tbs_temp" PAGESIZE 32K MANAGED BY SYSTEM USING 
(File '/home/mdpinst/MDPDB/tbs_temp')
EXTENTSIZE 256 BUFFERPOOL "BUFF_BUSINESS_TS";
-- 创建用户临时表空间
CREATE USER TEMPORARY TABLESPACE "tbs_user_temp" PAGESIZE 32K MANAGED BY SYSTEM USING 
(File '/home/mdpinst/MDPDB/tbs_user_temp')
EXTENTSIZE 256 BUFFERPOOL "BUFF_BUSINESS_TS";

CREATE SCHEMA "MDPUSR";

-- 对数据库和表空间进行授权
GRANT dbadm on database to user MDPUSR;
GRANT USE OF TABLESPACE "MDPUSERSAPCE" TO USER MDPUSR;
GRANT USE OF TABLESPACE "MDPINDEXSAPCE" TO USER MDPUSR;
GRANT USE OF TABLESPACE "TABSYS" TO USER MDPUSR;
GRANT USE OF TABLESPACE "IDXSYS" TO USER MDPUSR;
GRANT LOAD ON DATABASE TO USER MDPUSR;

CONNECT RESET;

 

你可能感兴趣的:(db2)