【DB2學習文檔之六】資料庫操作

來源:互聯網
上載者:User

作者:gnuhpc
出處:http://www.cnblogs.com/gnuhpc/

1.建立資料庫
db2 create database db_name
2.刪除資料庫
db2 drop database db

3.串連資料庫
db2 connect to sample
4.斷開資料庫連接
connect reset
terminate(這個命令會結束整個會話和前端進程,並且它是唯一能保證一定把後端進程關閉的結束命令)
(上述兩個可以在有工作進行時斷開)
Disconnect
(有工作進行則不能斷開)
5.備份資料庫
要檢查一下活動情況: db2 list active databases
若沒有活動則備份db2 backup database sample
具體操作見文檔16——定時備份的文檔。
6.恢複資料庫
db2 restore database sample
7. 更改 db2 日誌空間的大小

備忘:以下命令為了防止 db2 資料庫過份使用硬碟空間而設,僅用於開發人員自己機器上的 db2 ,如果是伺服器,則參數需要修改。

db2 UPDATE DB CFG FOR USING logretain OFF logprimary 3 logsecond 2 logfilsiz 25600;

如果頁大小是 4KB ,則以上命令建立 3 個 100M 的記錄檔,佔用 300MB 硬碟空間。 25600*4KB=102400KB 。

8.Database Administration Server (DAS)

它是一個後台進程,用來遠程進行圖形化管理。

在Linux、Unix中,需要建立一個DAS使用者,DB2ADMINSERVER變數存有這個使用者的值。

命令如下:

db2admin start Starts the DAS.
db2admin stop Stops the DAS.
dascrt Creates the DAS in Linux and UNIX.
dasdrop Drops the DAS in Linux and UNIX.
db2admin create Creates the DAS in Windows.
db2admin drop Drops the DAS in Windows.
get admin cfg Displays the DAS admin configuration file.
update admin cfg Updates the DAS admin configuration file.
reset admin cfg Resets the DAS admin configuration file to its default values.

9.使用DB2Governor進行記錄

使用命令db2govd可以記錄幾乎所有的行為和事件,這是進階管理命令,暫時不進行介紹~

作者:gnuhpc
出處:http://www.cnblogs.com/gnuhpc/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.