1、連接遠程DB2服務器
? 圖形界面:控制中心
??? 注意:默認安裝DB2的服務名稱為db2c_db2
???????? 使用TCP/IP協(xié)議連接時端口50000
? 命令:
UNCATALOG NODE TESTCATALOG TCPIP NODE TEST REMOTE toone-1eb06fba5 SERVER db2c_db2 REMOTE_INSTANCE
?DB2 SYSTEM? TOONE-1EB06FBA5 OSTYPE? WIN
TEST 節(jié)點名稱
toone-1eb06fba5? 遠程服務器名稱
db2c_db2 為服務名
DB2 實例名稱
2、啟動DB2數(shù)據(jù)庫
db2start
3、備份數(shù)據(jù)庫
BACKUP DATABASE命令。
實例:
--連接數(shù)據(jù)庫
CONNECT TO JMINNET;
--停頓數(shù)據(jù)庫
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;
--斷開連接
CONNECT RESET;
--備份
BACKUP DATABASE JMINNET TO "D:\2005-10-12備份\" WITH 1 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT
PROMPTING;
--連接數(shù)據(jù)庫
CONNECT TO JMINNET;
--取消停頓
UNQUIESCE DATABASE;
--斷開連接
CONNECT RESET;
4、常用命令,參看IBM開發(fā)網(wǎng)站
connect to <dbname>
[ [user <userid>] using <pwd>]
CLP 命令? 描述?
db2start? 啟動數(shù)據(jù)庫管理器實例。
db2stop? 停止數(shù)據(jù)庫管理器實例。
get dbm cfg 返回數(shù)據(jù)庫管理器配置設置。
get dbm cfg show detail 顯示數(shù)據(jù)庫管理器參數(shù)的當前值和延遲值(從 V8 起)。
1update dbm cfg using <p> <v> 將數(shù)據(jù)庫管理器配置參數(shù) <p> 更新為值 <v>。
get instance 返回 DB2INSTANCE 環(huán)境變量的值。
list active databases 列出活動的數(shù)據(jù)庫和連接數(shù)。
list application [show detail] 返回關于當前連接的應用程序的信息。
force application (h1 [,h2,..,hn]) 根據(jù)句柄號與特定應用程序斷開連接。
force application all 斷開所有應用程序與數(shù)據(jù)庫的連接。
attach to <node> user <userid> using <pwd>? 以用戶 <userid> 通過使用密碼 <pwd> 與標識為 <node> 的
遠程實例連接。
數(shù)據(jù)庫
create database <dbname> 創(chuàng)建名為 <dbname> 的數(shù)據(jù)庫。
activate database <dbname> 顯式地激活數(shù)據(jù)庫。
deactivate database <dbname> 顯式地使數(shù)據(jù)庫失效。
connect to <dbname>
[ [user <userid>] using <pwd>]? 根據(jù)需要,顯式地以用戶 <userid> 和密碼 <pwd> 與數(shù)據(jù)庫 <dbname> 連
接。
1update dbm cfg using <p> <v> 將數(shù)據(jù)庫管理器配置參數(shù) <p> 更新為值 <v>。
connect reset 斷開與當前數(shù)據(jù)庫的連接。
get db cfg show detail 顯示數(shù)據(jù)庫配置參數(shù)的當前值和延遲值(僅適用于 V8)。
get db cfg for <dbname> 返回數(shù)據(jù)庫 <dbname> 的數(shù)據(jù)庫配置設置。
update db cfg for <dbname> using <p> <v> 將數(shù)據(jù)庫 <dbname> 的數(shù)據(jù)庫配置參數(shù) <p> 更新為值 <v>。
list tables[for {user | all | system | schema <schemaname>}][show detail] 列出數(shù)據(jù)庫中的表。如果
沒有指定任何參數(shù),則缺省情況是列出當前用戶的表。
describe table <tablename> 顯示一個表或視圖的列信息。
list tablespaces [show detail] 顯示表空間的標識、名稱、類型、內(nèi)容和狀態(tài)。
list tablespace containers for <tablespace_id> [show detail] 顯示用 <tablespace_id> 指定的表空間
的容器信息。
quiesce tablespaces for table <tablename> reset 將表空間的狀態(tài)復位成正常(normal)。
連接性
catalog [admin] <protocol> node … 為協(xié)議 <protocol> 在節(jié)點目錄中創(chuàng)建一項。
list [admin] node directory 返回節(jié)點目錄的內(nèi)容。
catalog database <dbname>… 為數(shù)據(jù)庫 <dbname> 在數(shù)據(jù)庫目錄中創(chuàng)建一項。
list database directory [on <path>] 返回數(shù)據(jù)庫目錄的內(nèi)容。
性能
get monitor switches 返回會話監(jiān)控開關的狀態(tài)。
update monitor switches using <monitor> <on|off> 為 <monitor> 設置會話監(jiān)控開關的狀態(tài)。
reset monitor all 復位性能監(jiān)控程序值。
get snapshot for dbm 返回實例級別的性能信息。
get snapshot for all on <dbname> 為數(shù)據(jù)庫 <dbname> 在數(shù)據(jù)庫級別返回所有性能信息。
get snapshot for dynamic sql on <dbname> 返回動態(tài) SQL 高速緩存的內(nèi)容。
runstats on table <tbschema>.<tbname> 收集表 <tbname> 的統(tǒng)計信息。表名必須是用 <dbschema> 全限定
的。
reorgchk on table all 確定是否需要對表進行重組。這對于對所有表自動執(zhí)行 runstats 很有用。
reorg table <tablename> 通過重構行來消除“碎片”數(shù)據(jù)并壓縮信息,對表進行重組。
管理
export 將數(shù)據(jù)庫數(shù)據(jù)抽取到一個平面文件中。
import 通過使用 IMPORT 實用程序,將數(shù)據(jù)導入到數(shù)據(jù)庫。
load query table <tbname>
[to local-message-file][nosummary | summaryonly] [showdelta]? 返回 LOAD 實用程序的進度。
backup database <dbname> [to <path>] 執(zhí)行數(shù)據(jù)庫備份。
restore database <dbname> [from <path>] 執(zhí)行數(shù)據(jù)庫恢復。
get health snapshot for dbm 返回實例的正常快照信息(僅適用于 V8)。
get health snapshot for all on <dbname> 返回數(shù)據(jù)庫 <dbname> 的所有正常快照(僅適用于 V8)。
管理服務器
get admin cfg 返回管理服務器的配置設置。
update admin cfg using <p> <v> 將管理服務器配置參數(shù) <p> 更新為值 <v>。
應用程序開發(fā)
get routine into <filename> from [specific] procedure <routine-name>[hide body] 將 SQL 過程抽取成
二進制文件。
put routine from <filename> [owner <newowner>[use registers]] 從二進制文件部署 SQL 過程。
posted on 2006-09-14 09:38
水煮三國 閱讀(453)
評論(0) 編輯 收藏 所屬分類:
Database