Start Database: Start db2 service: db2start activate database instance: db2activatedatabaselt; db_namegt; view activated Database: db2listac
Start database: Start db2 service: db2start activate database instance: db2 activate database lt; db_namegt; view activated database: db2 list ac
Start the database:
Start the db2 service: db2start
Activate database instance: db2 activate database
View activated databases: db2 list active databases
Close the database:
Invalid database instance: db2 deactivate database
Disable 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 -Tablespace
View Database Configuration: db2 get db cfg
Connect to the database: db2 connect
Db2 connect User [user_name] using [password]
Disconnect the database: db2 connect reset/db2 terminate
Create Database: db2 create db
Delete database: db2 drop database (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
View deadlocks: db2 get snapshot for locks on
Db2 "select agent_id, tabname, lock_mode from table (snap_get_lock (' ') As aa"
Kill process: db2 force application (NUM)
Monitor SQL statements that consume a lot in DB2:
Eg :( DB_NAME = CMSDB)
Db2top-d CMSDB ----- view the resource consumption. Follow the prompts to press l. Application Handle is displayed, and Application Handle (stat) with high resource consumption is found)
Write down app handle.
Db2pd-d CMSDB-dyn-application>/tmp/db2pd1.txt ---- session Statements everywhere, ready for tuning
Set the connection mode (restart will take effect ):
Db2set DB2COMM = tcpip
Db2set DB2COMM =