After the last write, how do I export the data structure and data ([Tips] exporting table structures and data from DB2). Now I have finally finished writing how to import the table structure.
The first step is to create a database. You can use control center or command line. However, for this new database, I prefer command editor.
After opening, you can directly write the following SQL text:
Create Database mydb2
On 'd :'
Using codeset IBM-eucjp
Territory JP
Collate using system;
It seems that only the drive letter is recognized after "ON". After the drive letter is successfully identified, continue to enable "CE" and select "mydb2" in "target". In fact, "connect to mydb2;" is executed ;', the purpose is to create a schema. The concept of schema is that every household has a TV set, but its ownership is different.
Write the following SQL statement:
CREATE SCHEMA UT001 AUTHORIZATION MyDB2;
CREATE SCHEMA UT002 AUTHORIZATION MyDB2;
So far, the database and schema have been created, and the SQL file for table creation has been imported. For example:
Now, every time we start to execute the table creation file. In this case, you can use DB2 command line to perform operations.
You can directly write SQL files in CE and execute them directly. However, if DDL is used to export SQL files and execute them one by one, it will be very troublesome. At this time, I suggest using batch processing. we can write a BAT file, placed under IBM/sqllib/bin:
DB2 connect to mydb2
DB2 set current schema ut001
DB2-tvf D:/data/test1. SQL
DB2-tvf D:/data/test.2sql
DB2 commit work
DB2 terminate
Note: first, if there are not multiple schemas, you do not need to use the second row. The parameter-tvf in the second and third rows is explained as follows,
-F: Read the input file.
-T: Specifies the statement termination character.
-V send back current command
If each statement in the file ends with a carriage return, use-VF. Adding-T indicates that no statement ends.