以下的文章主要向大家講述的是DB2數據庫安裝的正確操作步驟,如果你對DB2數據庫安裝的正確操作步驟有興趣的話,以下的文章將會為你揭開它的神秘面紗,以下就是文章的詳細內容介紹,望大家借鑒。
一 DB2安裝過程
1 新建3個組,分別為管理組件das組,實例inst組,守護def組。隨後在三個組中分別加入對應的用戶:das,inst,和def。注意的是inst 用戶>同時屬於das組。為各個用戶建立目錄和密碼。
2 運行DB2SETUP後未出現向導,出現提示後退出的解決。
請不要執行DB2SETUP,請執行DB2_install,然後輸入DB2數據庫安裝的組件名字進行安裝。
3 創建實例
在/opt/IBM/db2/v8.1/instane/下分別執行
./dascrt -u dasuser
./dasicrt -w 32 -u defuser instuser #如未指定位寬,則會報錯說配置文件不能正常初始化。
在/cfg/下執行db2ln
4 設置
切換到instuser用戶下
$db2set -g DB2COMM = TCPIP #在全局或使用-i指定某個實例的連接屬性
5 啟動數據庫
$db2start #在啟動前請修改系統時間到2005年以前,否則會出現數據庫license過期的提示
建立樣表
$db2sampl
測試
- $db2 "select * from stuff"
二 DB2的初次使用
- $db2
- Command Line Processor for DB2 SDK 8.2.3
- You can issue database manager commands and SQL statements from the command
- prompt. For example:
- db2 => connect to sample
- db2 => bind sample.bnd
- For general help, type: ?.
- For command help, type: ? command, where command can be
- the first few keywords of a database manager command. For example:
- ? CATALOG DATABASE for help on the CATALOG DATABASE command
- ? CATALOG for help on all of the CATALOG commands.
- To exit db2 interactive mode, type QUIT at the command prompt. Outside
- interactive mode, all commands must be prefixed with 'db2'.
- To list the current command option settings, type LIST COMMAND OPTIONS.
- For more detailed help, refer to the Online Reference Manual.
- db2 => db2start
- DB20000I The DB2START command completed successfully.
- db2 => create db mydb
- DB20000I The CREATE DATABASE command completed successfully.
- db2 => connect to mydb user admin
- Enter current password for admin:
- Database Connection Information
- Database server = DB2/NT 8.2.3
- SQL authorization ID = ADMIN
- Local database alias = MYDB
- db2 => create schema myschema
- DB20000I The SQL command completed successfully.
- db2 => create table myschema.mytable(id int, name varchar(30))
- DB20000I The SQL command completed successfully.
- db2 => insert into myschema.mytable values(101,'Bruce Lu')
- DB20000I The SQL command completed successfully.
- db2 => select * from myschema.mytable
- ID NAME
- 101 Bruce Lu
- 1 record(s) selected.
- db2 => drop table myschema.mytable
- DB20000I The SQL command completed successfully.
- db2 => drop schema myschema restrict
- DB20000I The SQL command completed successfully.
- db2 => connect reset
- DB20000I The SQL command completed successfully.
- db2 => drop db mydb
- DB20000I The DROP DATABASE command completed successfully.
- db2 => db2stop
- DB20000I The DB2STOP command completed successfully.
- db2 => quit
- DB20000I The QUIT command completed successfully.
以上的相關內容就是對DB2數據庫安裝的介紹,望你能有所收獲。
延伸閱讀
詳解DB 2軟件下載及WINDOWS XP下的安裝步驟
如果您沒有DB2的安裝軟件,那麼您可以到IBM的官方網站上下載免費試用版,網址如下:http://www-01.ibm.com/software/cn/data/download/
圖1
獲得的安裝文件是一個壓縮包:
圖2