This document introduces two common methods for importing and exporting table structures in the DB2 database.
Method 1
In the object View window of the control center, select the data table of the table structure to be exported, press Ctrl or Shift to select multiple data tables, right click, and choose-> Generate DDL.
Method 2
◆ Step 1: Open the command line tool of DB2, create a new folder data under the BIN folder of the DB2 installation directory, and enter the directory.
Create this directory: mkdir data
Go to the directory: cd data
◆ Step 2: export the table structure. The command line is as follows:
Db2look-d dbname-e-a-x-I username-w password-o ddlfile. SQL
After successful execution, you will find the SQL file in the folder you just created.
◆ Step 3: export data. The command line is as follows:
Db2move databasename export-u username-p password
So far, data export has ended.
2. Export table data
Export to [path (example: D: "TABLE1.ixf)] of ixf select [field (example: * or col1, col2, col3)] from TABLE1;
Export to [path (example: D: "TABLE1.del)] of del select [field (example: * or col1, col2, col3)] from TABLE1;
Import table data