Oracle HTML output
In this small tutorial I will show you how you can display the output of the select command in a formatted HTML table from sqlPlus. Tutorial info:
Name: | Oracle HTML output |
Total steps: | 1 |
Category: | Oracle |
Date: | 2007-11-15 |
Level: | Beginner |
Product: | See complete product |
Viewed: | 35720 |
Bookmark Oracle HTML output
Step 1 - HTML output from sqlPlus
Oracle HTML output
Oracle is a very feature rich high end database, however sqlPlus is one of it's weakness. Time to time it you need to list the content of a table or view in Oracle using sqlPlus and it usually results a hard interpretable output. There is the possibility to set line size parameter and modify the display size of the columns but it takes to much time.
I nice solution would be to display the output in a HTML format. Fortunately we can do that. Now I will show you 2 solutions. The first one is working from the command line and the second one is working inside sqlPLus.
1. Generate Oracle HTML output from command line:
Code:
sqlplus -S -M "HTML ON TABLE 'BORDER="2"'" user/password @test.sql>test.html
In this example you need to create the test.sql file and put all your sql statements in this file. The result will be written into the test.html file.
2. Generate Oracle HTML output inside sqlPlus:
Code:
SET markup HTML on
spool test.html
SELECT * FROM mytable;
spool off
SET markup HTML off
In this case you can write all of your sql statements between the spool commands. The test.html file will be generated in the actual directory.
As you can see these solutions are not the best as you can view the files in a browser and not in sqlPlus, however in a lot of cases this solution makes your life easier.