This article mainly introduces the data movement function of the IBM DB2 database, this section describes how to use commands of the DB2 database to import and load data from files in a certain format to tables in the database.
The so-called data movement in DB2 includes:
1. import Data)
2. Data export (export)
3. load)
Both import and load use db2 commands to save data in files of a certain format to tables in the database.
Export refers to saving the data in the table of the db2 database to a file of a certain format.
The role of data movement:
To transfer data between different database management systems, data movement is usually the most practical method, because any database management system supports common file formats, this universal interface makes it easy to transfer data between different systems.
Among the three commands, export is the simplest. Because data is transferred from a table to a file, there is usually no error or illegal data.
Before explaining commands, first introduce the file format.
1. asc -- a non-bounded ascii file, which is an ascii plain stream. The rows in the data stream are separated by line delimiters, and each column in the row is defined by the start and end positions. For example:
- 10 head Office 160 corporate new york
- 15 new england 50 eastern boston
- 20 mid atlantic 10 eastern washington
- 38 south atlantic 30 eastern atlanta
- 42 great lakes 100 midwest chicago
- 51 plains 140 midwest dallas
- 66 pacific 270 western san francisco
- 84 mountain 290 western denver
2. del -- specifies an ascii file, which is also an ascii transfer stream. The rows in the data stream are separated by line delimiters, and the column values in the rows are separated by column delimiters. File Type modifiers can be used to modify the default values of these delimiters. For example:
- 10,"head office",160,"corporate","new york"
- 15,"new england",50,"eastern","boston"
- 20,"mid atlantic",10,"eastern","washington"
- 38,"south atlantic",30,"eastern","atlanta"
- 42,"great lakes",100,"midwest","chicago"
- 51,"plains",140,"midwest","dallas"
- 66,"pacific",270,"western","san francisco"
- 84,"mountain",290,"western","denver"
The above content is an introduction to the role of data movement in the IBM DB2 database. I hope you will have some gains.