Common DB2 commands

Source: Internet
Author: User
Tags db2 connect db2 connect to db2 create table db2 describe table

Start database: Start db2 service: db2start activate database instance: db2 activate database <db_name> View activated database: db2 list active databases
Shut down database: Invalid database instance: db2 deactivate database <db_name> shut down database Service: db2stop
View Database: db2 list db directory
View database applications: db2 list applications view database applications and processes: db2 list applications show detail View database tablespace: db2pd-db <db_name>-tablespace
View Database Configuration: db2 get db cfg for <db_name> connect to database: db2 connect to <db_name> db2 connect to <db_name> user [user_name] using [password] Disconnect the database: db2 connect reset/db2 terminate create database: db2 create db <db_name> delete database: db2 drop database <db_name> (if it cannot be deleted, try to disconnect the activated connection or restart db2)
List system tables: db2 list tables for system list all user tables: db2 list tables list all tables: db2 list tables for all list specific user tables: db2 list tables for schema [user]
Copy a table: db2 create table t1 like t2 display table structure: db2 describe table tablename query table: db2 "select * from table tablename where... "Run the SQL Script: db2-tvf scripts. SQL
View error code: db2? 10054 stop the activation connection: db2 force application all; \ db2 force application all; \ db2 force application all; \ db2stop to view the deadlock: db2 get snapshot for locks on <db_name> db2 "select agent_id, tabname, lock_mode from table (snap_get_lock ('<db_name>') as aa" kill a process: db2 force application (NUM) monitors SQL statements that consume a lot of data in DB2: eg :( DB_NAME = CMSDB) db2top-d CMSDB ----- view the resource consumption and press l as prompted. Application Handle appears, find the Application Handle (stat) with high resource consumption and write down the app handle . Db2pd-d CMSDB-dyn-application>/tmp/db2pd1.txt ---- the session statements are prepared for optimization.
Set the connection mode (which takes effect after restart): db2set DB2COMM = tcpipdb2set DB2COMM =

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.