DB2 Commands — Different ways of stopping database

db2

I'm hoping to get a more in-depth explanation of the following DB2 commands, which all relate to stopping the database in some way, and how they differ from each other.

How do DBAs think about these commands and decide which situations to apply them?

deactivate database
terminate
quiesce 
db2stop

The official documentation doesn't provide more than a couple sentences and usually defines the commands in terms of themselves:

DEACTIVATE DATABASE: This command deactivates the target database on all members in the
instance or, a specified member.

Or,

TERMINATE: Explicitly terminates the command line processor's back-end process.

After trying to research the difference between the commands, most online explanations consist of people simply parroting the documentation. But what is the real difference? Does anyone have an "in the trenches" view of which circumstances require which of these commands?

Best Answer

Ok, this is really simplified, but hopefully helpful.

DEACTIVATE is the opposite of ACTIVATE. ACTIVATE loads some of the database processes into memory to save time and performance on connections. Otherwise the first connection is where the database does this work. DEACTIVATE takes the processes out of memory. It only "completes" once everyone is logged out. You only have to DEACTIVATE if you ACTIVATE.

TERMINATE shuts down any current connections and any processes run by the command line processor (CLP). It does not necessarily "unload" processes from memory like DEACTIVATE does.

QUIESCE puts the database (or instance) into a "restricted mode" so only IDs with QUIESCE_CONNECT privilege can connect. This is useful for running certain upgrades, etc, when you need the database up, but do not want users on the system. UNQUIESCE takes the database (or instance) out of this mode.

db2stop actually stops the instance. This would be the equivalent of hitting the "off" button, so to speak. db2stop force is a stronger "off" that forces users off the system.

EDIT: As a side note, when you run db2start, if you run it as db2start admin mode, it starts the instance in a state of QUIESCE.