I use Oracle and I would like to export some data to Excel/csv by SQL query statement regularly on Windows, SQL query statement as below:
SELECT A.e,
a.f,
a.g,
b.h
FROM A
JOIN C ON C.e=A.e
JOIN B ON C.j=B.j;
Thanks so much for any advice.
Example for Windows test_csv.bat
sqlplus -s user/password@net_alias @csv.sql
csv.sql
set heading off
set termout OFF
SET FEEDBACK OFF
SET TAB OFF
set pause off
set verify off
SET UNDERLINE OFF
set trimspool on
set timing off
set echo off
set linesize 1000
set pagesize 0
SET COLSEP ';'
spool test.csv
SELECT A.e,
a.f,
a.g,
b.h
FROM A
JOIN C ON C.e=A.e
JOIN B ON C.j=B.j;
spool off
exit;