I use DB2 these years (four)

xiaoxiao2021-03-06  47

Continued: Restore Database

Recently, someone will ask me how to restore the database under the command line, I have made a more detailed explanation for everyone; later I feel that something is still written, so I want to write the idea of ​​this thing. I think it is still starting from telling the story. . . . . .

That is a winter, very cold and cold. At that time, I used IBM RS6000 small machine as a database server. At that time, it was the first time to touch this machine. I feel very fresh. After a few days, I truly realized how key to learning to use the CPL environment management database, because I haven't played the system, DB2CC can't start it, and after the problem is an AIX system environment variable. ). At that time, I suddenly lost there, because I just made a backup DROP database ready to retransmate to another place; after the development is also used. At this time, the problem is really a thing ~~ This time I need is calm, I recall the command line environment used in the backup, I must use it to recover the database, but how to redirect those table space? The problem is here, it is originally used to use the graphical interface to do the same, not considering using the command line, making it now so wolf. Hey! I know so, why bother?

Think about it or from the information center, but the luck is not bad, let me find it. There is an example in the Restore Database section of Command Reference. So I did it, the specific process is as follows:

Step 1: Create a new database, you need to pay attention to its character set, for example:

DB2 CREATE DB TEST ON / HOME / DB2INST1 Using Code GBK TERRITORY EZH_CN

CODESET GBK TERRITORY EN_CN is the command word for specifying Chinese character sets

Step 2: Restore the database that needs to be recovered to this newly built database, there will be a prompt information when this command is running, probably, the database you want to recover is trying to override a database, the original database Will be overwritten, you can choose Yes regardless of it, because the database is new.

DB2 Restore DB Test1 from / Home / DB2Inst1 / Dbback Taken at 20040330073123 INTO TEST Redirect WITHOUT ROLLING Forward;

In this command, you need to specify the timestamp to be restored to the database, the meaning of Redirect WITHOUT ROLLING FORWARD does not roll forward.

Step 3: Redirect the table space, I use the file type table space container here.

It is important to note here that you must know the type and size of the tablespace container in advance. You can view the number, type, and id of the database table space through the list tablespaces command. Then by command List TableSpace Containers for TableSpaceID (TableSpaceID displayed in the previous command) Show Detail View the size type and location of the tablespace container, as shown below:

TableSpace Containers for TableSpace 0

Container ID = 0

Name = / home / smith / smith / node0000 /

SQL00001 / SQLT0000.0

TYPE = PATH

Total Pages = 895USEABLE PAGES = 895

Accessible = yes

Next, decide to redirect the type position and size of the tablespace container. The Size of the redirected tablespace container cannot be less than the current value.

DB2 => Set TableSpace Containers for 4 Using (file '/ home / db2inst1 / long' 51200);

DB2 => Set TableSpace Containers for 3 Using (file '/ home / db2inst1 / temp' 51200);

DB2 => Set TableSpace Containers for 2 Using (file '/ home / db2inst1 / user' 102400);

Step 4: Formally restore the database and finish the work.

DB2 => restore DB Test1 Continue;

转载请注明原文地址:https://www.9cbs.com/read-79971.html

New Post(0)