db2建立資料庫

來源:互聯網
上載者:User

標籤:des   blog   http   使用   ar   strong   檔案   資料   art   

一、建資料表空間和資料庫

1.在db2ad、db2db和db2ap上均執行:

[sql] view plaincopyprint?

  1. db2set db2comm=tcpip  
  2. db2set db2codepage=1386  

db2set db2comm=tcpip

db2set db2codepage=1386

2.建立資料庫:

[sql] view plaincopyprint?

  1. db2 create db <dbname> using codeset gbk territory CN collate using identity  

db2 create db <dbname> using codeset gbk territory CN collate using identity

3.串連上資料庫:

[sql] view plaincopyprint?

  1. db2 "connect to  <dbname>"  

db2 "connect to  <dbname>"

4.建立緩衝池 + 建立資料表空間;
1).刪除舊的資料表空間:

[sql] view plaincopyprint?

  1. db2 drop tablespace  tablespace1, tablespace2, tablespace3  

db2 droptablespace  tablespace1, tablespace2,tablespace3

2).建立緩衝池:

[sql] view plaincopyprint?

  1. db2 create bufferpool bp32k all nodes size -1 pagesize 32k  

db2 createbufferpool bp32k all nodes size -1 pagesize 32k

bp32k為該緩衝池的名稱;
32K為頁大小;
size=-1表示使用預設的buffpage,而buffpage可以通過db2 get db cfg|grep -i buff參數查看到;
3).建立資料表空間:

[sql] view plaincopyprint?

  1. db2 "create regular tablespace  tablespace1 pagesize 32k managed by database using(file ‘/usr/yixiayizi/tablespace1‘ 5g) bufferpool bp32k"  
  2. db2 "create regular tablespace  tablespace2 pagesize 32k managed by database using(file ‘/usr/yixiayizi/tablespace2‘ 10g) bufferpool bp32k"  
  3. db2 "create regular tablespace  tablespace3 pagesize 32k managed by database using(file ‘/usr/yixiayizi/tablespace3‘ 2g) bufferpool bp32k"  

db2 "createregular tablespace  tablespace1 pagesize32k managed by database using(file ‘/usr/yixiayizi/tablespace1‘ 5g) bufferpoolbp32k"

db2 "createregular tablespace  tablespace2 pagesize32k managed by database using(file ‘/usr/yixiayizi/tablespace2‘ 10g) bufferpoolbp32k"

db2 "createregular tablespace  tablespace3 pagesize32k managed by database using(file ‘/usr/yixiayizi/tablespace3‘ 2g) bufferpoolbp32k"

注意(file ‘/usr/yixiayizi/tablespace1‘ 5g)的設定:
第一個參數:
 當指向外置盤時,file改為device;
 當指向檔案路徑時,為file;
第二個參數:需要是絕對路徑;
第三個參數:該資料表空間的大小;

db2建立資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.