Extracting data from DB2 using FTP

Data can be extracted remotely from DB2 and easily loaded into spreadsheets or other applications.

  1. Create a file containing the SQL to be used for extracting the data.
  2. Use FTP to connect to the system where DB2 is running and upload the SQL file. site filetype=seq
    put myquery.sql
  3. Extract the data to a different file name. site filetype=sql
    site db2=db2x
    site spread
    get myquery.sql myquery.dat
    db2x is the DB2 system that the data is to be extracted from. With site spread, the downloaded file will be in tab-delimited format, which makes it easier to load into most applications, such as Microsoft Excel. site nospread can be used for applications that do not support tab-delimited files.

Note that some FTP clients do not support the site command, but may allow the command to be executed by preceding it with quote.

quote site ...

If the system that the data is to be downloaded to has an FTP server running, the data can be sent from an FTP client running on the host system. This allows the data to be sent automatically by scheduling the transfer as a batch job. In this case, the locsite command is used to set parameters on the local system where the FTP client is running.

locsite filetype=sql
locsite db2=db2x
locsite spread
put myquery.sql myquery.dat

Last updated Friday November 16, 2006


Printer-friendly PDF* format:

FTP Access to DB2

How To Guides for IBM DB2 UDB Databases

This Section

You are currently viewing this page in XHTML 1 Style Sheet* format (* see Clicklets for more infomation). This document is also available in XHTML 1*XML*HTML 4*HTML 5 Style Sheet*HTML 5 XML*HTML 5 non-XML* XHTML 2* XHTML Mobile* WML Mobile* and printer-friendly PDF* formats. This is accomplished with Single Source Publishing, a content management system that uses templates in XSLT style sheets provided by XML Styles .com to transform the source content for various content delivery channels. There is also RDF* metadata that describes the content of this document.