Formatting Reports
SQL*Plus reports are columnar in nature. SQL*Plus provides you with the ability to define column headings and display formats for each column in a report. You may also define page headers and footers, page and line breaks, and summary calculations such as totals and subtotals.
Column Headings
Specify column headings using the HEADING clause of the COLUMN command:
COLUMN employee_name HEADING "Employee Name"
Either single or double quotes may be used to enclose the heading text. The resulting heading will look like this:
Employee Name -------------
To specify a multiline heading, use the vertical bar
(|
) character to specify the location of the line
break. For example:
COLUMN employee_name HEADING "Employee|Name"
The resulting multiline heading will look like this:
Employee Name ---------
Headings of text columns are aligned to the left. Headings of numeric columns are aligned to the right. Use the JUSTIFY clause to alter that behavior:
COLUMN employee_name HEADING "Employee|Name" - JUSTIFY RIGHT COLUMN employee_name HEADING "Employee|Name" - JUSTIFY CENTER
Use SET HEADSEP to change the line-break character to something other than a vertical bar. Use SET UNDERLINE to change the underline character to something other than a hyphen.
Column Formats
Specify display formats using the FORMAT clause of the COLUMN command. For numeric fields, format specifications can be quite detailed—controlling the length, the number of decimal places, and the punctuation used in the number. For ...
Get Oracle SQL*Plus Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.