Numeric Conversions: PostgreSQL
You can convert between numeric values and their string
representations using the following functions, where
number can be any numeric type:
TO_CHAR(number,format) TO_NUMBER(string,format)
PostgreSQL’s number format elements closely follow Oracle’s. They are listed in Table 1-10.
Table 1-10. PostgreSQL’s numeric format elements
Element | Description |
|---|---|
| Prefix: dollar sign
( |
| Location of comma.
Consider |
| Location of period.
Consider |
| Significant digit. Leading zeros. |
| Significant digit. Leading blanks. |
| Prefix: returns zero as blanks. |
| Location of ISO currency symbol. |
| Location of decimal point. |
| Suffix: use scientific notation. |
| Prefix: removes leading/trailing blanks. |
| Location of group separator. |
| Location of local currency symbol. |
| Suffix: trailing minus
( |
| Suffix: angle brackets
( |
| Roman numerals, upper- or lowercase. Output-only. |
| Prefix: leading plus
( |
| Prefix: use minimum
number of characters (text-minimum). Output-only. |
| Specifies location of
Euro symbol ( |
| Multiplies the number to
the left of the |
| Use hexadecimal notation.
Output-only. Precede with |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access