How can Oracle convert a string into a number?

Oracle has the ability to convert strings to numbers using the TO_NUMBER function.

Syntax:
TO_NUMBER(string, [format], [nls_numeric_characters])

Description of parameters:

  1. String: the string to be converted to a number.
  2. Format: an optional parameter that specifies the formatting of numbers. If this parameter is not provided, the default format of the database will be used.
  3. nls_numeric_characters: Optional parameter that specifies the country/region setting for numeric characters. If this parameter is not provided, the database’s default setting will be used.

Convert the string ‘123’ to a number:
SELECT TO_NUMBER(‘123’) FROM DUAL;

Output: 123

bannerAds