DB2 CLP 命令的快速參考
2024-09-06 23:58:06
供稿:網(wǎng)友
轉(zhuǎn)到db2官方網(wǎng)站:
以下是最常用的 db2 clp 命令的快速參考。雖然不是一份完整的參考,但這篇文檔對(duì)于任何剛接觸 db2 的用戶來說,可以證明是案邊有價(jià)值的參考材料。反饋意見可以發(fā)送至 [email protected]。
方括號(hào)中的參數(shù)是可選參數(shù),尖括號(hào)中的內(nèi)容表示變量。例如,connect 的語法是:
connect to <dbname>[ [user <userid>] using <pwd>]
這意味著,通過 connect 命令以 user1 身份使用密碼 mypass 與數(shù)據(jù)庫 sample 連接可以有下列形式:
connect to sampleconnect to sample user user1connect to sample user user1 using mypass
根據(jù)命令的作用域來組織所有命令。對(duì)于任何 clp 命令,您都可以輸入加上前綴問號(hào)(“?”)的關(guān)鍵字,以查看其完整的語法。
祝愉快!
實(shí)例
clp 命令描述db2start啟動(dòng)數(shù)據(jù)庫管理器實(shí)例。db2stop停止數(shù)據(jù)庫管理器實(shí)例。get dbm cfg返回?cái)?shù)據(jù)庫管理器配置設(shè)置。get dbm cfg show detail顯示數(shù)據(jù)庫管理器參數(shù)的當(dāng)前值和延遲值(從 v8 起)。1update dbm cfg using <p> <v>將數(shù)據(jù)庫管理器配置參數(shù) <p> 更新為值 <v>。get instance返回 db2instance 環(huán)境變量的值。list active databases列出活動(dòng)的數(shù)據(jù)庫和連接數(shù)。list application [show detail]返回關(guān)于當(dāng)前連接的應(yīng)用程序的信息。force application (h1 [,h2,..,hn])根據(jù)句柄號(hào)與特定應(yīng)用程序斷開連接。force application all斷開所有應(yīng)用程序與數(shù)據(jù)庫的連接。attach to <node> user <userid> using <pwd>以用戶 <userid> 通過使用密碼 <pwd> 與標(biāo)識(shí)為 <node> 的遠(yuǎn)程實(shí)例連接。
數(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斷開與當(dāng)前數(shù)據(jù)庫的連接。get db cfg show detail顯示數(shù)據(jù)庫配置參數(shù)的當(dāng)前值和延遲值(僅適用于 v8)。get db cfg for <dbname>返回?cái)?shù)據(jù)庫 <dbname> 的數(shù)據(jù)庫配置設(shè)置。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ù),則缺省情況是列出當(dāng)前用戶的表。describe table <tablename>顯示一個(gè)表或視圖的列信息。list tablespaces [show detail]顯示表空間的標(biāo)識(shí)、名稱、類型、內(nèi)容和狀態(tài)。list tablespace containers for <tablespace_id> [show detail]顯示用 <tablespace_id> 指定的表空間的容器信息。quiesce tablespaces for table <tablename> reset將表空間的狀態(tài)復(fù)位成正常(normal)。
連接性
catalog [admin] <protocol> node …為協(xié)議 <protocol> 在節(jié)點(diǎn)目錄中創(chuàng)建一項(xiàng)。list [admin] node directory返回節(jié)點(diǎn)目錄的內(nèi)容。catalog database <dbname>…為數(shù)據(jù)庫 <dbname> 在數(shù)據(jù)庫目錄中創(chuàng)建一項(xiàng)。list database directory [on <path>]返回?cái)?shù)據(jù)庫目錄的內(nèi)容。
性能
get monitor switches返回會(huì)話監(jiān)控開關(guān)的狀態(tài)。update monitor switches using <monitor> <on|off>為 <monitor> 設(shè)置會(huì)話監(jiān)控開關(guān)的狀態(tài)。reset monitor all復(fù)位性能監(jiān)控程序值。get snapshot for dbm返回實(shí)例級(jí)別的性能信息。get snapshot for all on <dbname>為數(shù)據(jù)庫 <dbname> 在數(shù)據(jù)庫級(jí)別返回所有性能信息。get snapshot for dynamic sql on <dbname>返回動(dòng)態(tài) sql 高速緩存的內(nèi)容。runstats on table <tbschema>.<tbname>收集表 <tbname> 的統(tǒng)計(jì)信息。表名必須是用 <dbschema> 全限定的。reorgchk on table all確定是否需要對(duì)表進(jìn)行重組。這對(duì)于對(duì)所有表自動(dòng)執(zhí)行 runstats 很有用。reorg table <tablename>通過重構(gòu)行來消除“碎片”數(shù)據(jù)并壓縮信息,對(duì)表進(jìn)行重組。
管理
export將數(shù)據(jù)庫數(shù)據(jù)抽取到一個(gè)平面文件中。import通過使用 import 實(shí)用程序,將數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫。load query table <tbname>
[to local-message-file][nosummary | summaryonly] [showdelta]返回 load 實(shí)用程序的進(jìn)度。backup database <dbname> [to <path>]執(zhí)行數(shù)據(jù)庫備份。restore database <dbname> [from <path>]執(zhí)行數(shù)據(jù)庫恢復(fù)。get health snapshot for dbm返回實(shí)例的正??煺招畔ⅲ▋H適用于 v8)。get health snapshot for all on <dbname>返回?cái)?shù)據(jù)庫 <dbname> 的所有正常快照(僅適用于 v8)。
管理服務(wù)器
get admin cfg返回管理服務(wù)器的配置設(shè)置。update admin cfg using <p> <v>將管理服務(wù)器配置參數(shù) <p> 更新為值 <v>。
應(yīng)用程序開發(fā)
get routine into <filename> from [specific] procedure <routine-name>[hide body]將 sql 過程抽取成二進(jìn)制文件。put routine from <filename> [owner <newowner>[use registers]]從二進(jìn)制文件部署 sql 過程。