Using RDBMS-specific dumps like MySQL's "SELECT INTO OUTFILE" is probably faster. But in case your RDBMS doesn't have one or you want something that is portable across all DBI-accessible RDBMSs, here's an example. You can substitute any DBD for XBase and use any SELECT statement that is supported by that DBD. Under the hood, SQL::Statement will use that DBD to read row by row from the source and use Text::CSV_XS to write row by row to the target.

To use different separators, delimters, or escapes, use DBD::CSV's csv_tables, for example for a so-called "Tab Delimted" file with *nix line endings:

$dbhC->{csv_tables}->{outTable} = { file => 'foo/bar.csv', sep_char => "\t", eol => '\012', };
If you omit the csv_tables defintion, then the table name will be used for the filename and the separator will be a comma, the delimiter a quote mark and the line ending windows-style '\015\012'.

#!/usr/bin/perl use warnings; use strict; use DBI; my $dbhX = DBI->connect('dbi:XBase(RaiseError=1):'); my $dbhC = DBI->connect('dbi:CSV(RaiseError=1):'); my $select = $dbhX->prepare("SELECT * FROM inTable"); $select->execute(); $dbhC->do("CREATE TABLE outTable AS IMPORT(?)",{},$select); __END__