IBM DB2
Home > Ask the Data Management Experts > DBMS and data warehousing Questions & Answers > Data export command: Migration from a DB2 table to a flat file
Ask The Data Management Expert: Questions & Answers
EMAIL THIS

Data export command: Migration from a DB2 table to a flat file

Craig Mullins, Years 2005-2006 EXPERT RESPONSE FROM: Craig Mullins, Years 2005-2006

Pose a Question
Other Data Management Categories
Meet all Data Management Experts
Become an Expert for this site


Enterprise IT tips and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 18 April 2007
We are trying to export data from a DB2 table to a flat file by the following command:

db2 -tvf file.sql -z file.out

But it displays the output as below (i.e., it produces output including the sql, column name and the message ?EURoe2 record(s) selected?EUR?):

select tabname from syscat.tables where tabschema = 'VSC'
TABNAME
VEHICLE_TEMP
VSC_DASHBOARD_INTER

2 record(s) selected.

But we need only the records in the output file as appears below:

VEHICLE_TEMP
VSC_DASHBOARD_INTER

Please help us with this query.


>
EXPERT RESPONSE
You need to run an export command specifying the proper file format. The export command exports data from a database to an operating system file, which can be in one of several external file formats.

The following information is required when exporting data using the export command/utility:

  • An SQL SELECT statement specifying the data to be exported.
  • The path and name of the operating system file that will store the exported data.
  • The format of the data in the file. This format can be IXF, WSF, or DEL.

You might want to download a (free) copy of the IBM DB2 Data Movement Utilities Guide and Reference which contains information on how to formulate your export command and definitions of each of the various types of formats.

Quickly though, perhaps you are interested in creating a comma-delimited file. In that case, you would use the DEL format (delimited ASCII). A Delimited ASCII (DEL) file is a sequential ASCII file with row and column delimiters. Each DEL file is a stream of ASCII characters consisting of cell values ordered by row, and then by column. Rows in the data stream are separated by row delimiters; within each row, individual cell values are separated by column delimiters. When creating an ASCII delimited file (specifying a comma as the delimiter) you're file output would look something like this:

"Smith, Bob",4973,15.46
"Jones, Bill",12345,16.34
"Williams, Sam",452,193.78

Here is an example of an export requesting ASCII delimited output:

db2 export to test.del of del select tabname from syscat.tables where tabschema ='VSC';

  • Learn how using the data export command or copy utility is the best way to backup a database with SQL.


Sound Off! -   Be the first to post a message to Sound Off!


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
DBMS and data warehousing
Data warehousing, data mining and data querying: Terms and definitions
The difference between data definition language (DDL) and data manipulation language (DML)
What is an operational data store vs. a data warehouse?
Can a dimension table be a fact table for another data mart?
Top three database management system (DBMS) trends
Can I have two data warehouses?
Database administrator job roles: Organizing the DBAs
Data modeling for data warehouse projects
Data warehouse testing
Data warehouse development: Four strategic steps

IBM DB2
IBM DB2 basics
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 4
DB2 looks to enterprise information management to fend off Microsoft
DB2 tools and products for Linux, UNIX and Windows: The basics
Understanding IBM DB2: Product history and strategy
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 3
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 2
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 1
IBM DB2 9 Fundamentals certification (Exam 730): Sample question No. 7
IBM DB2 9 Fundamentals certification (Exam 730): Sample question No. 8

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2005 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts