Practically this recipe is linked with the previous one. Here, we will continue to remove the partitions 3 and 4 from the database.
Getting ready
Before deleting a partition, our first concern would be to make sure that the partition contains no data. Therefore, verification will be the first operation to be executed. If database partitions are empty, we can proceed further with removal. In this recipe, we will verify and remove the partitions 3 and 4, added previously, in the Adding database partitions recipe in this chapter.
How to do it...
You can perform these operations with Control Center or using the command line.
Using Control Center
In Control Center, navigate to instance db2instp, and right-click on Open Database partition servers. Next, right-click on the partition number and choose Drop….
Follow these steps, as instructed by the wizard:
Drop Database Partition from Database Partition Groups
Redistribute Data
Drop Database Partitions from Instance
Using the command line
In order to remove partitions, we have to switch the current partition to the one that we want to drop. We have the possibility to switch between partitions by setting the DB2NODE environment variable to the number of partitions. The main reason to use DB2NODE is that the drop dbpartitionnum verify command, used for verification, has no option to specify the partition number. Therefore, it must be used on the current node.
Note
Every time before you switch between partitions, use the terminate command to close the backend connection, otherwise you will get an error.
First, issue the terminate command to close any remaining backend connection:
[db2instp@nodedb21 ~]$ db2 "drop dbpartitionnum verify" SQL6034W Database partition "3" is not being used by any databases. [db2instp@nodedb21 ~]$
The database partition is clear, so we will proceed with dropping partition 3:
[db2instp@nodedb21 ~]$ db2stop drop dbpartitionnum 3 SQL6076W Warning! This command will remove all database files on the node for this instance. Before continuing, ensure that there is no user data on this node by running the DROP NODE VERIFY command. Do you want to continue ? (y/n)y 06/28/2011 16:08:54 2 0 SQL1064N DB2STOP processing was successful. 06/28/2011 16:08:54 1 0 SQL1064N DB2STOP processing was successful. 06/28/2011 16:08:55 4 0 SQL1064N DB2STOP processing was successful. 06/28/2011 16:09:05 3 0 SQL1064N DB2STOP processing was successful [db2instp@nodedb21 ~]$