SoFunction
Updated on 2025-04-14

DB2 programming skills (eight)

The db2 tutorial you are watching is: DB2 programming skills (8). 4.2 Create Database
create database head using codeset IBM-eucCN territory CN;
This can support Chinese.


4.3 Manually make remote database (alias) configuration
db2  catalog tcpip  node   node1  remote   172.28.200.200 server  50000
db2  catalog db    head   as     test1 at  node   node1

Then you can use:
   db2 connect to test1  user …  using …
Connect to the head library

4.4 Stop starting the database instance
db2start
db2stop (force)


4.5 Connecting to the database and looking at the current connection to the database
Connect to the database
db2  connect to head user db2inst1  using db2inst1

Current connection to the database
db2  connect
4.6 Stop starting the database head
db2  activate  db  head
db2  deactivate db  head
It should be noted that if there is a connection, using deactivate db does not work.
If the database is started with activated db, you must use deactivate db to stop the database. (Of course, if it is db2stop, it will also stop).
Use activate db, which can reduce the waiting time during the first connection.
If Database is started by connecting to the database instead of using activated db, db will automatically stop after all connections exit.

4.7 View and stop the database current application
View the application:
db2   list   applications  show  detail 

Authorization ID | Application Name | Application Handle | Application ID | Serial Number # Agent | Coordinator | Status | Status Change Time | DB Name | DB Path |                                                                                                                                                                                                                                        �

Among them: 1. The first part of the application identification is the IP address of the application, but it is represented in hexadecimal.
2. Pid/thread is the thread number you see under Unix.

Stop the application:
db2 "force application(236)"
db2 “force application all”

Where: The 236 is the application handle in view.