Here you will find list of Oracle Number Format elements:
Format element | Description |
---|---|
, | Returns a comma in the specified position it is possible to specify multiple commas. |
. | Returns a period in the specified position. |
$ | Returns a leading dollar sign. |
0 | Returns leading or trailing zeros (0). |
9 | Returns value with the specified number of digits with a leading space if positive or with a leading minus if negative. |
B | Returns blanks for the integer part of a fixed point number when the integer part is zero. |
C | Returns in the specified position the ISO currency symbol. Defoult currency value is set in the NLS_ISO_CURRENCY parameter. |
D | Returns in the specified position the decimal character, which is the current value of the NLS_NUMERIC_CHARACTER parameter. The default is a period. |
EEEE | Returns a value in scientific notation. |
FM | Returns a value without blanks (leading and trailing). |
G | Returns in the specified position the group separator. The defoult value is set in the NLS_NUMERIC_CHARACTER parameter. You can specify multiple group separators in a number format model. |
L | Returns in the specified position the local currency symbol. Defoult currency value is set in the NLS_CURRENCY parameter. |
MI | Returns negative value with a trailing minus (-) sign.
Returns positive value with a trailing blank. |
PR | Returns negative value in <>.
Returns positive value with a leading and trailing blank. |
RN | Returns a value as Roman numerals in uppercase.
Allowed value is an integer between 1 and 3999. |
rn | Returns a value as Roman numerals in lowercase.
Allowed value is an integer between 1 and 3999. |
S | Returns value with a leading or trailing minus (-) or plus (+) sign. |
TM | The text minimum number format model returns the smallest number of characters possible. This element is case insensitive. |
U | Returns in the specified position the defoult currency symbol. The current value of the NLS_DUAL_CURRENCY parameter. |
V | Returns a value multiplied by 10n and if necessary, round it up. |
X | Returns the hexadecimal value of the specified number of digits. If the specified number is not an integer, Oracle Database will round it to an integer. |
In examples below are shown conversions from number to char with different numbers and format elements.
SELECT TO_CHAR(number, 'format_element') FROM dual;
number | ‘format_element’ | results |
---|---|---|
-55555 |
55555S |
'55555-' |
0 |
99.99 |
' .00' |
+0.5 |
99.99 |
' .50' |
-0.5 |
99.99 |
' -.50' |
+0.55 |
90.99 |
' 0.55' |
-0.5 |
90.99 |
' -0.50' |
0 |
9999 |
' 0' |
+222.55 |
999.99 |
' 222.55' |
-222.55 |
999.99 |
'-222.55' |
+222.55 |
FM999.09 |
'222.55' |
+555.0 |
FM999.009 |
'555.00' |
+55.55 |
L99.99 |
' $55.55' |
+55.5 |
FML99.9 |
'$55.5' |
SQL Performance Tuning