首页 > 数据库 > DB2 > 正文

DB2 CLP 命令的快速参考

2020-03-09 22:29:25
字体:
来源:转载
供稿:网友

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

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

connect to <dbname>[ [user <userid>] using <pwd>]

这意味着,通过 connect 命令以 user1 身份使用密码 mypass 与数据库 sample 连接可以有下列形式:

connect to sampleconnect to sample user user1connect to sample user user1 using mypass

根据命令的作用域来组织所有命令。对于任何 clp 命令,您都可以输入加上前缀问号(“?”)的关键字,以查看其完整的语法。

祝愉快!

实例
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>]执行数据库备份。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 过程。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表