Home > Database > Mysql Tutorial > 常用的DB2命令

常用的DB2命令

WBOY
Release: 2016-06-07 17:35:14
Original
1181 people have browsed it

启动数据库:启动db2服务:db2start激活数据库实例:db2 activate database lt;db_namegt;查看激活状态的数据库:db2 list ac

启动数据库:
启动db2服务:db2start
激活数据库实例:db2 activate database 
查看激活状态的数据库:db2 list active databases


关闭数据库:
失效数据库实例:db2 deactivate database
关闭数据库服务:db2stop


查看数据库:db2 list db directory

查看数据库应用:db2 list applications
查看数据库应用和进程号:db2 list applications show detail
查看数据库表空间:db2pd -db -tablespace
查看数据库配置:db2 get db cfg for
连接数据库:db2 connect to
                    db2 connect to user[user_name] using [password]
断开数据库连接:db2 connect reset/db2 terminate
创建数据库:db2 create db
删除数据库:db2 drop database   (如果不能删除,尝试断开激活的连接或者重启db2)


列出系统表:db2 list tables for system
列出所有用户表:db2 list tables
列出所有表:db2 list tables for all
列出特定用户表:db2 list tables for schema [user]


复制一张表:db2 create table t1 like t2
显示表结构:db2 describe table tablename
查询表:db2 "select * from table tablename where ..."
执行SQL脚本:db2 -tvf scripts.sql


查看错误代码信息:db2 ? 10054
 
停止激活的连接:db2 force application all;\db2 force application all;\db2 force application all;\db2stop
 
查看死锁: db2 get snapshot for locks on
                  db2 "select agent_id,tabname,lock_mode from table(snap_get_lock('')) as aa"
杀掉进程: db2 force application(NUM)
 
 监控DB2消耗多的SQL语句:
eg:(DB_NAME=CMSDB)
db2top -d CMSDB  -----查看消耗资源 按照提示按 l,出现Application Handle,找到资源消耗大的Application Handle(stat)
记下app handle。
db2pd -d CMSDB -dyn -application > /tmp/db2pd1.txt    ----到处会话语句,,准备进行调优


设置连接方式(重启才会生效):
db2set DB2COMM=tcpip
db2set DB2COMM=         

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template