Oracle table to html file & Excel

Oracle table to html file 

$sqlplus -S -M "HTML ON TABLE 'BORDER="2"'" username@Ora10g @script.sql>filename.html
ex: - where script.sql contains:
select col1, col2 from table_name;
exit 

Oracle tables to Excel

set echo off pagesize 0 head off feed off veri off
set trimspool on feedback off
spool FILE_NAME.csv
select COL1 || ',' || COL2 || ',' || COL3 || ',' ||........ from TABLE_NAME;
spool off

If table data contain any 'comma' in middle , then follow this below steps: -

set echo off pagesize 0 head off feed off veri off
set trimspool on feedback off
spool FILE_NAME.txt
select COL1 || '~' || COL2 || '~' || COL3 || '~' ||........ from TABLE_NAME;
spool off

open the .txt file in MS-Excel. Selecting the separator option with '~'

No comments:

Post a Comment