DB2 Database Operations

Source: Internet
Author: User
Tags db2

Extracting database structure DDL using Db2look

Extracting DDL
$ db2look–d testdb–a–e–x–o testdb.sql

To export all the data in the specified database:

$ db2move testdb export–u db2inst1–p thepasswd

Exporting data using the DB2 export directive

Unlike the export features of the db2move mentioned above, DB2 export is a more granular exporting tool that supports three types of data file formats: DEL, WSF, IXF.

The following example exports the data from table Mytbl in database TestDB and stores it under Directory/home/backup.

To establish a connection to the database:
$ db2
DB2 = Connect to TestDB user Db2inst1 using thepasswd

Export in del format:
DB2 = Export To/home/backup/mytbl.txt of del select * Frommytbl

Export in IXF format:
DB2 = export TO/HOME/BACKUP/MYTBL.IXF of IXF SELECT * FROMMYTBL

Importing data using the DB2 import directive

Import and export are a pair of directives that have a corresponding relationship, and a little different is that import supports four formats: ASC, DEL, WSF, IXF, and export only supports three (see the description of the corresponding section above).

The following example imports the data file/home/movedata/mytbl.ixf into the database mytestdb.
$ db2
DB2 = Connect to mytestdb user Db2inst1 using THEPASSWD
DB2 = Import from/home/movedata/mytbl.ixf of ixf insert Intomytbl
DB2 = Commit Work
DB2 = Connect Reset
DB2 = quit

DB2 Database Operations

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.