19.06.2013 Views

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.3 LOAD and UNLOAD delimited input and output<br />

In V7, the LOAD utility input file is required to be of positional <strong>for</strong>mat. If you want to move data<br />

to <strong>DB2</strong> <strong>for</strong> z/<strong>OS</strong>, you must write a program to convert the data into the positional <strong>for</strong>mat that<br />

the LOAD utility can understand, or use INSERT statements, thereby not exploiting the<br />

per<strong>for</strong>mance advantage that the LOAD utility offers <strong>for</strong> a large amount of data.<br />

In <strong>DB2</strong> V8, the LOAD utility is enhanced to accept data from a delimited file. The UNLOAD<br />

utility is also enhanced to produce a delimited file when unloading the data. These<br />

enhancements help to simplify the process of moving or migrating data into and out of <strong>DB2</strong><br />

<strong>for</strong> z/<strong>OS</strong>.<br />

Re<strong>for</strong>matting data <strong>for</strong> <strong>DB2</strong> (be<strong>for</strong>e V8)<br />

Re<strong>for</strong>matting data <strong>for</strong> <strong>DB2</strong> is a very time consuming procedure. Prior to <strong>DB2</strong> V8, you can load<br />

data only from an input flat file, either a partitioned data set or a regular flat file. The file must<br />

include length in<strong>for</strong>mation <strong>for</strong> those fields that become VARCHAR columns in a <strong>DB2</strong> table.<br />

Re<strong>for</strong>matting the data <strong>for</strong> <strong>DB2</strong> means adding 2 bytes of binary data to the beginning of such a<br />

field. These 2 bytes contain a binary number representing the length of the data within the<br />

field. The following steps were needed to re<strong>for</strong>mat data <strong>for</strong> <strong>DB2</strong> <strong>for</strong> z/<strong>OS</strong>.<br />

1. Unload the data from a table residing on another relational database and transmit the file<br />

to z/<strong>OS</strong> and store it (either as member in a PDS, or as a sequential file).<br />

2. Write a program, possibly using REXX, to determine the length of the variable character<br />

data and generate the 2 byte binary length fields. Also the program should output a file<br />

with the positions and length of the fields which can be useful to set up LOAD utility<br />

statements.<br />

3. Prepare <strong>for</strong> a input control file used <strong>for</strong> a program, describing where is the beginning of<br />

each field and what kind of data will be encountered in input file records.<br />

4. Run the program, input the data from the other RDBMS and the input control file.<br />

5. Setup the LOAD utility control statement using the output of the program and specifying<br />

the generated input data in INDDN in the JCL statement, and then run the LOAD utility to<br />

load data into <strong>DB2</strong>. See Example 6-2 <strong>for</strong> an example of the LOAD statement.<br />

Example 6-2 Sample LOAD statement<br />

LOAD DATA INDDN(CPRSRECS) LOG NO RESUME YES<br />

INTO TABLE PAOLOR2.DATA_TYPE<br />

(DATA_TYPE P<strong>OS</strong>ITIN(1) VARCHAR,<br />

DESCRIPTION P<strong>OS</strong>ITION(9) VARCHAR)<br />

Delimited file input and output<br />

In V8, the LOAD utility accepts a delimited file, and the UNLOAD utility can produce a<br />

delimited file. Most relational databases including <strong>DB2</strong> on Linux, UNIX, Windows, Oracle®<br />

and Sybase can unload data in delimited <strong>for</strong>mat, where each record is a row, and columns<br />

are separated by commas, <strong>for</strong> example. So this enhancement eases dramatically the import<br />

or export of a large amount of data from other operating system plat<strong>for</strong>ms to <strong>DB2</strong> <strong>for</strong> z/<strong>OS</strong><br />

and vice versa. And also this eliminates the requirement to write a program to convert<br />

non-z/<strong>OS</strong> plat<strong>for</strong>m data into positional <strong>for</strong>mat <strong>for</strong> the LOAD utility, so you can avoid the data<br />

re<strong>for</strong>matting process described above.<br />

For instance, if you want to move data from a spreadsheet from a Windows workstation to<br />

<strong>DB2</strong> <strong>for</strong> z/<strong>OS</strong>, you need to take the following steps:<br />

► Save the spreadsheet data in comma separated value (CSV) <strong>for</strong>mat<br />

270 <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 Per<strong>for</strong>mance <strong>Topics</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!