20071207 formatting oracle sqlplus output - plembo/onemoretech GitHub Wiki
title: Formatting Oracle sqlplus output link: https://onemoretech.wordpress.com/2007/12/07/formatting-oracle-sqlplus-output/ author: lembobro description: post_id: 593 created: 2007/12/07 21:37:02 created_gmt: 2007/12/07 21:37:02 comment_status: open post_name: formatting-oracle-sqlplus-output status: publish post_type: post
Formatting Oracle sqlplus output
OK. So I know there is a fine art to formatting reports using sqlplus, but I’m a bit lazy lately, so I’m having a hard time sitting down to learn how to do it. Well, I just found a shortcut. The HTML markup function. That’s right, you can turn on HTML formatting inside an sqlplus session and then spool your results to a nicely formatted file that can be read in any web browser or other HTML aware tools, like Open Office calc. Heck, you could even write a perl script to replace the HTML formatting with simple text formatting (like lots of commas to build a csv file). Here are the commands:
SQL> set markup HTML on
SQL> spool /tmp/report.html
SQL> select * from some_table;
* * *
SQL> spool off
SQL> set markup HTML off
SQL>
The hardest thing about this article was figuring out how to display a literal “>” in the examples. Thanks to the people over at the Web Design Group for this handy set of charts.
Copyright 2004-2019 Phil Lembo