Re: linux/unix script to dump csv files for each table in db

From: Mladen Gogala <no_at_email.here.invalid>
Date: Wed, 1 Dec 2010 17:38:24 +0000 (UTC)
Message-ID: <pan.2010.12.01.17.38.22_at_email.here.invalid>



On Wed, 01 Dec 2010 06:52:26 -0800, Mark D Powell wrote:
> On Nov 30, 7:45 am, syd_p <sydneypue..._at_yahoo.com> wrote:

>> Hi,
>>
>> I am using a very simple script to dump out some csv files from all the
>> tables in a mysql db.
>> Well actually they are psv files cos they are separted by a pipe
>> symbol.
>>
>> But anyway I want to do the same thing with oracle 10G. Any ideas on
>> how to do this?
>> Please help if you can!
>>
>> -Syd
>>
>> #!/bin/bash
>>
>> db=nb276
>> user=root
>> pass=xxxx
>>
>> for table in $(mysql -u$user -p$pass  $db -Be "SHOW tables" | sed 1d);
>> do \
>>  echo "exporting $table.."
>>  mysql  $db -u$user -p$pass -e "SELECT * FROM $table" | sed
>>  's/\t/|/g'> $db.$table.psv
>>
>> done
> 
> How do I export a database table to a flat file ?
> 
> 	http://www.jlcomp.demon.co.uk/faq/flatfile.html
> 
> HTH -- Mark D Powell --

There are, of course, tools like this one:

http://mgogala.byethost5.com/dump2csv.zip

I have the new revision which will be put on the website tonight. The new revision has the binary flag turned on, to do the trick with the binary data and allows the choice of separators. The default separator is changed from the comma to tab.

-- 
http://mgogala.byethost5.com
Received on Wed Dec 01 2010 - 11:38:24 CST

Original text of this message