DB2常用命令

 

實例

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

將數據庫數據抽取到一個平面文件中。
export to btpoper.txt of <?XML:NAMESPACE PREFIX = ST1 />del select * from btpoper(,號分割)
export to btpoper.txt of del modified by coldel| select * from btpoper(|號分割)
export to btpoper.txt of del select * from btpoper where brhid='907020000'

import 通過使用 IMPORT 實用程序,將數據導入到數據庫。
import from btpoper.txt of del insert into btpoper(,號分割)
import from btpoper.txt of del modified by coldel| insert into btpoper(|號分割)
load query table <tbname>
[to local-message-file][nosummary | summaryonly] [showdelta]
返回 LOAD 實用程序的進度。
backup database <dbname> [to <path>] 執行數據庫備份。
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 過程。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章