Home > Database > Oracle > How to convert number to string in oracle

How to convert number to string in oracle

青灯夜游
Release: 2022-03-17 16:21:52
Original
29480 people have browsed it

In Oracle, you can use the to_char() function to convert numbers into strings. This function can convert numbers into strings in a specified format. The syntax is "SELECT TO_CHAR (number, format to be converted) [ FROM data table];".

How to convert number to string in oracle

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

In Oracle, you can use the to_char() function to convert numbers into strings.

Syntax:

TO_CHAR(d|n[,fmt])
Copy after login

Can convert dates and numbers into strings in a specified format. Fmt is the format string

for the formatting of numbers. The formatting characters are:

Parameters

Example

Description

##9

999

Display the number at the specified position

.

9.9

Returns the decimal point at the specified position

,

99,99

Returns a comma at the specified position

$

$999

Returns a dollar sign at the beginning of the number

EEEE

9.99EEEE

Scientific notation

L

L999

Add a local currency symbol before the number

PR

999PR

If the number is negative, use angle brackets to indicate it

ParameterDescription9A value with the specified number of digits0 Values ​​with leading zeros . (period) , (comma) Group (thousands) delimiterPRNegative values ​​in angle bracketsS Negative value with negative sign (use localization) L Currency symbol (use localization) DGGroup separator (use localization)MIMinus sign at specified position (if number < 0) PLPositive sign at the indicated position (if number > 0)SGPositive/negative sign at the indicated positionRNRoman numerals (enter between 1 and 3999) TH or thConvert to ordinal numbersVMove EEEEScientific notation. Not supported now.
decimaldot
DecimalDot (use localization)
n digits (decimal) (see notes)
Code demonstration: TO_CHAR processing of numbers


SELECT TO_CHAR(-123123.45,&#39;L9.9EEEEPR&#39;)"date" FROM dual;
Copy after login

How to convert number to string in oracle

Recommended tutorial: "

Oracle Tutorial

The above is the detailed content of How to convert number to string in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template