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

From: syd_p <sydneypuente_at_yahoo.com>
Date: Wed, 1 Dec 2010 10:41:31 -0800 (PST)
Message-ID: <0a8ce165-7fc3-4051-a646-5137b2638a0a_at_z19g2000yqb.googlegroups.com>



On 30 Nov, 17:51, joel garry <joel-ga..._at_home.com> wrote:
> On Nov 30, 4: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
>
> http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html
>
> Using select * is considered bad form, because there is nothing to say
> the columns will be in any particular order.
>
> Also see the documentation for sqlplus, you can set the output field
> separator in that tool.
>
> There are tables to describe the structure of tables, in addition to
> the desc command.  Search for USER_TAB_COLS athttp://tahiti.oracle.com
> for example.
>
> For perl fans, a bit of googling finds things likehttp://www.orafaq.com/usenet/comp.databases.oracle.tools/2004/08/28/0...
>
> Welcome to cdos!  http://dbaoracle.net/readme-cdos.htm
>
> jg
> --
> _at_home.com is bogus.http://news.techworld.com/storage/3250972/oracle-users-have-big-priva...

good point about the select * thanks Received on Wed Dec 01 2010 - 12:41:31 CST

Original text of this message