Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: export to ascii file
Raul Sanchez <rsanchez_at_lingocd.com> wrote in article
<333DC0E2.1FAB_at_lingocd.com>...
> Hi,
>
> I would like to know how or where I might find information on how
> to export a table to an ascii file in ORACLE (for example, in SYBASE
> I would use the following:
>
> bcp databaseName..tableName out dataFile -c .....
>
> In order words, what is the equivalent to this statement above
> in ORACLE. Thanx for you kind help in advance.
>
> --Raul
>
Try this:
contents of tabexp.sql:
(cut below & name "tabexp.sql")
REM Tab-Separated Export Creator REM for Oracle7 / SQL*Plus REM REM Created 11/15/96 REM By Ken Shirey REM Oracle Database Administrator REM Commerical Data Systems REM email: shireyk_at_flash.net REM REM This program may be freely distributed, provided REM it retains this header. Use at your own risk.REM
select decode(datatype, number,'to_char(', date ,'to_char(', char ,'rtrim(' , NULL ) || column_name || decode(datatype, number,') ', date ,')', NULL ) || ' || chr(9) || ' from all_tab_columns where table_name = upper('&1');
SQL> @tabexp EMP SQL> Creating command file for table: EMP ... SQL> Now exporting table: EMP ... SQL> Export Completed. SQL>
SQL> desc emp
empno number(5) NOT NULL ename varchar2(50) NULL mgrid number(5) NULL hiredate date NULL wasted_space char(1000) NOT NULL
The results:
% more cmd.sql
Select rtrim(
to_char(EMPNO) || chr(9) || ename || chr(9) || mgrid || chr(9) ||