Before you can issue an SQL statement, you have to connect to a database. To connect to a database, enter the command:
db2 CONNECT TO database USER userID USING password
|[db2inst1@mercury dbbackup]$ db2 CONNECT TO sample USER db2inst1 using password|
Once you have connected to a database, you can then issue SQL statements or DB2 commands against that database. For example, to select all of the rows from the EMPLOYEE table in the SAMPLE database, issue this command:
|[db2inst1@mercury dbbackup]$ db2 “SELECT * FROM employee”|
Using : connect reset
|[db2inst1@mercury dbbackup]$ db2 connect reset|
Connect Reset breaks a connection to a database , but does not terminate the back-end process.
Using : db2 terminate
|[db2inst1@mercury dbbackup]$ db2 terminate|
If an application is connected to a database, or a process is in the middle of a unit of work, TERMINATE causes the database connection to be lost.
An internal commit is then performed.
Although TERMINATE and CONNECT RESET both break the connection to a database, only TERMINATE results in termination of the back-end process.
It is recommended that TERMINATE be issued prior to executing the db2stop command. This prevents the back-end process from maintaining an attachment to a database manager instance that is no longer available