"How To" Guides for IBM DB2 UDB Databases

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

Next: JDBC 

Home > Computers > Databases > IBM DB2 > FTP

Viewing mobile website page. Switch to WML or Full HTML