O'Reilly logo

Oracle SQL Plus Pocket Reference, 2nd Edition by Jonathan Gennick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Formatting Text Reports

SQL*Plus reports are columnar in nature. The program lets you 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"

You can use either single or double quotes to enclose the heading text. The resulting heading looks 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 looks 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

You can specify display formats with 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 text and date fields, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required