DB2 CLP 命令的快速参考

** 转到db2官方网站: **
以下是最常用的 DB2 CLP 命令的快速参考。虽然不是一份完整的参考,但这篇文档对于任何刚接触 DB2 的用户来说,可以证明是案边有价值的参考材料。反馈意见可以发送至 [email protected]

方括号中的参数是可选参数,尖括号中的内容表示变量。例如,CONNECT 的语法是:

connect to
  1<dbname>
  2    [ [user <userid>] using <pwd>]
  3
  4这意味着,通过 CONNECT 命令以 user1 身份使用密码 mypass 与数据库 sample 连接可以有下列形式: 
  5    
  6    
  7    Connect to sample
  8    Connect to sample user user1
  9    Connect to sample user user1 using mypass
 10    
 11
 12根据命令的作用域来组织所有命令。对于任何 CLP 命令,您都可以输入加上前缀问号(“?”)的关键字,以查看其完整的语法。 
 13
 14祝愉快! 
 15
 16**实例**   
 17
 18
 19&gt; **CLP 命令** |  **描述**  
 20&gt; ---|---  
 21&gt; db2start  |  启动数据库管理器实例。   
 22&gt; db2stop  |  停止数据库管理器实例。   
 23&gt; get dbm cfg  |  返回数据库管理器配置设置。   
 24&gt; get dbm cfg show detail  |  显示数据库管理器参数的当前值和延迟值(从 V8 起)。   
 25&gt; 1update dbm cfg using <p> <v> |  将数据库管理器配置参数 <p> 更新为值 <v>。   
 26&gt; get instance  |  返回 DB2INSTANCE 环境变量的值。   
 27&gt; list active databases  |  列出活动的数据库和连接数。   
 28&gt; list application [show detail]  |  返回关于当前连接的应用程序的信息。   
 29&gt; force application (h1 [,h2,..,hn])  |  根据句柄号与特定应用程序断开连接。   
 30&gt; force application all  |  断开所有应用程序与数据库的连接。   
 31&gt; attach to <node> user <userid> using <pwd> |  以用户 <userid> 通过使用密码 <pwd> 与标识为 <node> 的远程实例连接。   
 32  
 33**数据库**   
 34
 35
 36&gt; create database <dbname> |  创建名为 <dbname> 的数据库。   
 37&gt; ---|---  
 38&gt; activate database <dbname> |  显式地激活数据库。   
 39&gt; deactivate database <dbname> |  显式地使数据库失效。   
 40&gt; connect to <dbname>   
 41&gt;  [ [user <userid>] using <pwd>]  |  根据需要,显式地以用户 <userid> 和密码 <pwd> 与数据库 <dbname> 连接。   
 42&gt; 1update dbm cfg using <p> <v> |  将数据库管理器配置参数 <p> 更新为值 <v>。   
 43&gt; connect reset  |  断开与当前数据库的连接。   
 44&gt; get db cfg show detail  |  显示数据库配置参数的当前值和延迟值(仅适用于 V8)。   
 45&gt; get db cfg for <dbname> |  返回数据库 <dbname> 的数据库配置设置。   
 46&gt; update db cfg for <dbname> using <p> <v> |  将数据库 <dbname> 的数据库配置参数 <p> 更新为值 <v>。   
 47&gt; list tables[for {user | all | system | schema <schemaname>}][show detail]  |  列出数据库中的表。如果没有指定任何参数,则缺省情况是列出当前用户的表。   
 48&gt; describe table <tablename> |  显示一个表或视图的列信息。   
 49&gt; list tablespaces [show detail]  |  显示表空间的标识、名称、类型、内容和状态。   
 50&gt; list tablespace containers for <tablespace_id> [show detail]  |  显示用 <tablespace_id> 指定的表空间的容器信息。   
 51&gt; quiesce tablespaces for table <tablename> reset  |  将表空间的状态复位成正常(normal)。   
 52  
 53**连接性**   
 54
 55
 56&gt; catalog [admin] <protocol> node …  |  为协议 <protocol> 在节点目录中创建一项。   
 57&gt; ---|---  
 58&gt; list [admin] node directory  |  返回节点目录的内容。   
 59&gt; catalog database <dbname>…  |  为数据库 <dbname> 在数据库目录中创建一项。   
 60&gt; list database directory [on <path>]  |  返回数据库目录的内容。   
 61  
 62**性能**   
 63
 64
 65&gt; get monitor switches  |  返回会话监控开关的状态。   
 66&gt; ---|---  
 67&gt; update monitor switches using <monitor> <on|off> |  为 <monitor> 设置会话监控开关的状态。   
 68&gt; reset monitor all  |  复位性能监控程序值。   
 69&gt; get snapshot for dbm  |  返回实例级别的性能信息。   
 70&gt; get snapshot for all on <dbname> |  为数据库 <dbname> 在数据库级别返回所有性能信息。   
 71&gt; get snapshot for dynamic sql on <dbname> |  返回动态 SQL 高速缓存的内容。   
 72&gt; runstats on table <tbschema>.<tbname> |  收集表 <tbname> 的统计信息。表名必须是用 <dbschema> 全限定的。   
 73&gt; reorgchk on table all  |  确定是否需要对表进行重组。这对于对所有表自动执行 runstats 很有用。   
 74&gt; reorg table <tablename> |  通过重构行来消除“碎片”数据并压缩信息,对表进行重组。   
 75  
 76**管理**   
 77
 78
 79&gt; export  |  将数据库数据抽取到一个平面文件中。   
 80&gt; ---|---  
 81&gt; import  |  通过使用 IMPORT 实用程序,将数据导入到数据库。   
 82&gt; load query table <tbname>   
 83&gt;  [to local-message-file][nosummary | summaryonly] [showdelta]  |  返回 LOAD 实用程序的进度。   
 84&gt; backup database <dbname> [to <path>]  |  执行数据库备份。   
 85&gt; restore database <dbname> [from <path>]  |  执行数据库恢复。   
 86&gt; get health snapshot for dbm  |  返回实例的正常快照信息(仅适用于 V8)。   
 87&gt; get health snapshot for all on <dbname> |  返回数据库 <dbname> 的所有正常快照(仅适用于 V8)。   
 88  
 89**管理服务器**   
 90
 91
 92&gt; get admin cfg  |  返回管理服务器的配置设置。   
 93&gt; ---|---  
 94&gt; update admin cfg using <p> <v> |  将管理服务器配置参数 <p> 更新为值 <v>。   
 95  
 96**应用程序开发**   
 97
 98
 99&gt; get routine into <filename> from [specific] procedure <routine-name>[hide body]  |  将 SQL 过程抽取成二进制文件。   
100&gt; ---|---  
101&gt; put routine from <filename> [owner <newowner>[use registers]]  |  从二进制文件部署 SQL 过程。</newowner></filename></routine-name></filename></v></p></v></p></dbname></dbname></path></dbname></path></dbname></tbname></tablename></dbschema></tbname></tbname></tbschema></dbname></dbname></dbname></monitor></on|off></monitor></path></dbname></dbname></protocol></protocol></tablename></tablespace_id></tablespace_id></tablename></schemaname></v></p></dbname></v></p></dbname></dbname></dbname></v></p></v></p></dbname></pwd></userid></pwd></userid></dbname></dbname></dbname></dbname></dbname></node></pwd></userid></pwd></userid></node></v></p></v></p></pwd></userid></dbname>
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus