In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
DB2 backup and restore the DB2-related documents written in the past 16 years, but I haven't used DB2 since I changed my job. I almost forgot. One db2 backup/restore backup and recovery 1.1 backup
Db2 backup/restore backup and recovery is only applicable to databases on the same operating system platform.
Command format: db2 backup db to
Note: all connections to the database should be disconnected before backup, and then back up after disconnection. The directory name is the directory where the backed-up files are stored.
Example:
Db2 backup database sample to d:\ backup
If the database is in use, it may return the wrong "SQL1035N"
The database is currently in use. "SQLSTATE=57019" needs to stop the service, use the command:
Db2 force application all
Db2 backup db sample to d:\ backup
1.2 recovery
Command format: db2 restore db from
Example: db2 restore db sample from d:\ backup
-delete the original sample database (simulate database recovery)
Restore database sample
Db2 restore db sample from D:\ DB2\ backup
View the database
II: db2move backup and recovery 2.1backup
1) first connect to the database to be exported, as in this example, export the database nctest:
Db2 connect to nctest user db2inst1 using db2inst1
The parameter user is followed by the specified user, and the password of the specified user is specified after using. If not specified, the default user will be used to log in.
2) use db2look to export definition statements for data objects
Db2look-d nctest-e-o ncdb.sql-I db2inst1-w db2inst1
The argument-o in the command means to export the definition of the data object to the specified file
The parameter-I is followed by the specified user, and the password of the user is specified after-w. If not specified, the default user will be used to log in.
3) use the db2move command to export data from database objects
Db2move nctest export-u db2inst1-p db2inst1
Connect to the database sample
Script sample.sql for creating objects by exporting a sample database through db2look
Db2look-d sample-e-o sample.sql-I user name-w user password
Export data
Db2move sample export-u username-p user password
Sample.sql: a script for creating data objects
Export.out: database export log
Db2move.lst: including the name of the exported object and the schema to which each object belongs
-if you export the Times wrong SQL3107W, you need to change the character set of the environment variable.
2.2 recovery
Import SAMPLE database data into test database
Db2 create database test
When you restore a NC database through db2move, you can create the database and tablespaces according to the database building script 1.sql.
Db2 connect to test user username using user password
A.sql---create_table.sql
B.sql---create_foreign.sql
Modify the sample.sql script to change the database name and tablespace name in the script to the actual name
Cut the statement in the sample.sql script that creates a foreign key into another script (create_foreign.sql)
If you import data, there will be an error when importing the corresponding foreign key table data before importing the master table data, so you need to create the foreign key after successfully importing the foreign data.
Create a table structure
Db2-tvf a.sql
...
Import data
Db2 test import-io insert-u user name-p user password
Import foreign key constraints
Db2-tvf b.sql
View data
.
Welcome to follow my Wechat official account "IT Little Chen" and learn and grow together!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.