TO_CHAR - Convert Number to String - Oracle to MySQL Migration

In Oracle, TO_CHAR function can convert a numeric value to string using the specified format. In MySQL, you can use FORMAT function as well as other string functions and expressions.

Oracle:

  -- Convert the price to string format
  SELECT TO_CHAR(1000, 'FM$9,999,999') FROM dual;
  # $1,000

MySQL:

  -- Convert the price to string format
  SELECT CONCAT('$', FORMAT(1000, 0));
  # $1,000

Conversion Examples

Typical conversion examples:

Oracle MySQL
TO_CHAR(1000, 'FM$9,999,999') CONCAT('$', FORMAT(1000, 0))
TO_CHAR(1000, '9,999,999') FORMAT(1000, 0)

Database and SQL Migration Tools

About SQLines

SQLines offers services and tools to help you migrate databases and applications. For more information, please contact us at support@sqlines.com.

You could leave a comment if you were logged in.