How to import and export a single table in db2

Source: Internet
Author: User
Tags db2 connect db2 connect to import database

1. Export the entire database table structure, method, and stored procedure, and execute the script.:
Db2look-d dbname-e-o db. SQL-I username-w password
Db2-tvf db. SQL

2. Export and Import single table data:
Export: db2move dbname export-tn tablename-u db2user-p psw
Import: db2move dbname import-u db2user-p psw

3. database backup and recovery:
BACKUP: db2 backup database dbname
Recovery: db2 restore database dbname

4. Use the db2move command to export and import database data
To export initialization data from another database, first go to the exported directory, run DB2cmd, and then run the following command: db2move dbname export-u username-p password. Note: dbname is the name of the original database, and username is the username and password is the password.
Restore command: db2move dbname import-u username-p password

5. Others:.
Export to a file to obtain the SQL statement
Db2look-d cqyancao-e-o db. SQL-I db2user-w psw
Database Name to output file name username and password
Example: db2look-d DEPARTMENT-u walid-e-o db2look. SQL
-- This generates DDL statements for all tables and associated objects created by user WALID.
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-d DEPARTMENT-z myscm1-e-o db2look. SQL
-- This will generate DDL statements for all tables with the schema name MYSCM1
-- DDL of all associated objects created by $ USER is also generated.
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-d DEPARTMENT-u walid-m-o db2look. SQL
-- This generates an UPDATE statement to capture statistics about the table/alias created by the user WALID.
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-d DEPARTMENT-u walid-e-wrapper W1-o db2look. SQL
-- This will generate DDL statements for all tables created by user WALID
-- DDL will also be generated for all Union objects created by user WALID of the package W1
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-d DEPARTMENT-u walid-e-server S1-o db2look. SQL
-- This will generate DDL statements for all tables created by user WALID
-- DDL for all associated objects created by user WALID of server S1 will also be generated
-- The db2look output is sent to a file named db2look. SQL.

Db2 backup and import of a single table
Db2 connect to Database Name user Login name using Login Password
> Db2 export to t1.ixf of ixf select * from Table Name
> Db2 import from t1.ixf of ixf insert into target table name or new table name

There are two types of del (file format) and wsf data formats for export and export, but the ixf format is the most comprehensive,
Contains the table structure information to restore the deleted table.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.