In our normal development, we may encounter the problem of judging whether a column is composed of numbers. We all know that Oracle does not provide us with such a ready-made function. According to my experience, I have summed up two effective methods (column name: column, table name: table)
Use the translate + 1
What should be noted here is: the third parameter of the translate function is a space, not ”, because if the third parameter of translate is empty, it will always return ”, which will not achieve the purpose of filtering pure numbers. In this way, all the numbers are converted into spaces. If all the numbers are composed of numbers, they will be empty after trim. Of course, if you want to exclude empty items, you can write as follows:
2. Use regexp_ Like function:
Here we should pay attention to:regexp_ The like function is not available in all Oracle versions.regexp_ Like is the four functions that Oracle supports regular expressions: regexp_ like，regexp_ replace，regexp_ instr,regexp_ For more details on this, please pay attention to the relevant documents.
In summary, if regexp supports_ Regular function is recommended. If it is not supported, trim + translate is used.