SQL*Plus Format Elements

The COLUMN, ACCEPT, SET NUMBER, TTITLE, BTITLE, REPHEADER, and REPFOOTER commands allow you to control data formats using what is called a format specification. A format specification is a string of characters that tells SQL*Plus exactly how to format a number, date, or text string when it is displayed.

Formatting Numbers

Table 1.4 shows the format elements that may be used when formatting numeric output.

Table 1-4. Numeric Format Elements

Format

Element

Function

9

Represents a digit in the output.

0

Marks the spot at which you want to begin displaying leading zeros.

$

Includes a leading dollar sign in the output.

,

Places a comma in the output.

.

Marks the location of the decimal point.

B

Forces zero values to be displayed as blanks.

MI

Adds a trailing negative sign to a number and may be used only at the end of a format string.

S

Adds a + or - sign[a] to the number and may be used at either the beginning or end of a format string.

PR

Causes negative values to be displayed within angle brackets. For example, -123.99 will be displayed as <123.99>.

D

Marks the location of the decimal point.

G

Places a group separator (usually a comma) in the output.

C

Marks the place where you want the ISO currency indicator to appear. For U.S. dollars, this will be USD.

L

Marks the place where you want the local currency indicator to appear. For U.S. dollars, this will be the dollar sign character.

V

Displays scaled values. The number of digits to the right of the V indicates ...

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.