How can I determine if a string is numeric in SQL?

AndrewL picture AndrewL · Apr 14, 2011 · Viewed 77.2k times · Source

In a SQL query on Oracle 10g, I need to determine whether a string is numeric or not. How can I do this?

Answer

Chandu picture Chandu · Apr 14, 2011

You can use REGEXP_LIKE:

SELECT 1 FROM DUAL
WHERE REGEXP_LIKE('23.9', '^\d+(\.\d+)?$', '')