1、串連遠程DB2伺服器
圖形介面:控制中心
注意:預設安裝DB2的服務名稱為db2c_db2
使用TCP/IP協議串連時連接埠50000
命令:
UNCATALOG NODE TESTCATALOG TCPIP NODE TEST REMOTE toone-1eb06fba5 SERVER db2c_db2 REMOTE_INSTANCE
DB2 SYSTEM TOONE-1EB06FBA5 OSTYPE WIN
TEST 節點名稱
toone-1eb06fba5 遠程伺服器名稱
db2c_db2 為服務名
DB2 執行個體名稱
2、啟動DB2資料庫
db2start
3、備份資料庫
BACKUP DATABASE命令。
執行個體:
--串連資料庫
CONNECT TO JMINNET;
--停頓資料庫
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;
--中斷連線
CONNECT RESET;
--備份
BACKUP DATABASE JMINNET TO "D:/2005-10-12備份/" WITH 1 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT
PROMPTING;
--串連資料庫
CONNECT TO JMINNET;
--取消停頓
UNQUIESCE DATABASE;
--中斷連線
CONNECT RESET;
4、常用命令,參看IBM開發網站
connect to <dbname>
[ [user <userid>] using <pwd>]
CLP 命令 描述
db2start 啟動資料庫管理員執行個體。
db2stop 停止資料庫管理員執行個體。
get dbm cfg 返回資料庫管理員配置設定。
get dbm cfg show detail 顯示資料庫管理員參數的當前值和延遲值(從 V8 起)。
1update dbm cfg using <p> <v> 將資料庫管理員配置參數 <p> 更新為值 <v>。
get instance 返回 DB2INSTANCE 環境變數的值。
list active databases 列出活動的資料庫和串連數。
list application [show detail] 返回關於當前連線應用程式程式的資訊。
force application (h1 [,h2,..,hn]) 根據控制代碼號與特定應用程式中斷連線。
force application all 斷開所有應用程式與資料庫的串連。
attach to <node> user <userid> using <pwd> 以使用者 <userid> 通過使用密碼 <pwd> 與標識為 <node> 的遠程執行個體串連。
資料庫
create database <dbname> 建立名為 <dbname> 的資料庫。
activate database <dbname> 顯式地啟用資料庫。
deactivate database <dbname> 顯式地使資料庫失效。
connect to <dbname>
[ [user <userid>] using <pwd>] 根據需要,顯式地以使用者 <userid> 和密碼 <pwd> 與資料庫 <dbname> 串連。
1update dbm cfg using <p> <v> 將資料庫管理員配置參數 <p> 更新為值 <v>。
connect reset 斷開與當前資料庫的串連。
get db cfg show detail 顯示資料庫配置參數的當前值和延遲值(僅適用於 V8)。
get db cfg for <dbname> 返回資料庫 <dbname> 的資料庫配置設定。
update db cfg for <dbname> using <p> <v> 將資料庫 <dbname> 的資料庫配置參數 <p> 更新為值 <v>。
list tables[for {user | all | system | schema <schemaname>}][show detail] 列出資料庫中的表。如果
沒有指定任何參數,則預設情況是列出目前使用者的表。
describe table <tablename> 顯示一個表或視圖的列資訊。
list tablespaces [show detail] 顯示資料表空間的標識、名稱、類型、內容和狀態。
list tablespace containers for <tablespace_id> [show detail] 顯示用 <tablespace_id> 指定的資料表空間
的容器資訊。
quiesce tablespaces for table <tablename> reset 將資料表空間的狀態複位成正常(normal)。
串連性
catalog [admin] <protocol> node … 為協議 <protocol> 在節點目錄中建立一項。
list [admin] node directory 返回節點目錄的內容。
catalog database <dbname>… 為資料庫 <dbname> 在資料庫目錄中建立一項。
list database directory [on <path>] 返回資料庫目錄的內容。
效能
get monitor switches 返回會話監控開關的狀態。
update monitor switches using <monitor> <on|off> 為 <monitor> 設定會話監控開關的狀態。
reset monitor all 複位效能監控程式值。
get snapshot for dbm 返回執行個體層級的效能資訊。
get snapshot for all on <dbname> 為資料庫 <dbname> 在資料庫層級返回所有效能資訊。
get snapshot for dynamic sql on <dbname> 返回動態 SQL 快取的內容。
runstats on table <tbschema>.<tbname> 收集表 <tbname> 的統計資訊。表名必須是用 <dbschema> 全限定
的。
reorgchk on table all 確定是否需要對錶進行重組。這對於對所有表自動執行 runstats 很有用。
reorg table <tablename> 通過重構行來消除“片段”資料並壓縮資訊,對錶進行重組。
管理
export 將資料庫資料幫浦到一個一般檔案中。
import 通過使用 IMPORT 公用程式,將資料匯入到資料庫。
load query table <tbname>
[to local-message-file][nosummary | summaryonly] [showdelta] 返回 LOAD 公用程式的進度。
backup database <dbname> [to <path>] 執行Database Backup。
restore database <dbname> [from <path>] 執行資料庫恢複。
get health snapshot for dbm 返回執行個體的正常快照資訊(僅適用於 V8)。
get health snapshot for all on <dbname> 返回資料庫 <dbname> 的所有正常快照(僅適用於 V8)。
管理伺服器
get admin cfg 返回管理伺服器的配置設定。
update admin cfg using <p> <v> 將管理伺服器配置參數 <p> 更新為值 <v>。
應用程式開發
get routine into <filename> from [specific] procedure <routine-name>[hide body] 將 SQL 過程抽取成
二進位檔案。
put routine from <filename> [owner <newowner>[use registers]] 從二進位檔案部署 SQL 過程。