Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Defy Murphy's Law with DB2 Backup and Restore-2 : Page 2




Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

Create the Data to Backup
Before you can back up data, you need to create a database with a table and populate it with the data. Use the DB2 Command Line Processor to create your database:

db2 => create db backdem

Next, connect to the database you just created:

db2 => connect to backdem user db2admin using db2admin

Next, create a simple table consisting of three columns. Table 1 shows the structure and sample data you'll store inside the table.

Table 1: Structure and Sample Data Values for secretidentities Table
SuperHeroName (Varchar 45) * SuperHeroIdentity (Varchar 45)
Superman Clark Kent
Spiderman Peter Parker
Batman Bruce Wayne
* Denotes primary key

To create your table, use the following command:

db2 => create table secretidentities(superheroname varchar(45) primary key not null,
superheroidentity varchar(45) not null)

Use the following syntax to populate the first row in Table 1:

db2 => insert into secretidentities values (Superman,Clark Kent)

Repeat the command to populate the table with the other two rows.

Backup! Backup! Backup!
Now back up your database. The following command backs up the database backdem to the directory c:\dbback:

db2 => backup database backdem user db2admin using db2admin to c:\dbback

After issuing this command, you should receive a prompt similar to the following:

Backup successful. The timestamp for this backup image is: 20031119181253.

The timestamp uniquely identifies each database backup. You should make note of it so you can later specify the database backup from which you want to restore.

You can also use the DB2 Control Center to perform your backup. Just right click on the database you want to backup and choose the "Backup" option from the context menu as shown in Figure 1.

Click to enlarge
Figure 1: Using the Control Center to Backup

The resulting DB2 backup wizard helps you create a backup task via a graphical interface (see Figure 2).

Click to enlarge
Figure 2: The Backup Wizard

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date