CHECK CONSTRAINT of string to contain only digits. (Oracle SQL)

前端 未结 8 1824
一向
一向 2020-12-20 12:22

I have a column, say PROD_NUM that contains a \'number\' that is left padded with zeros. For example 001004569. They are all nine characters long.

I do not use a num

相关标签:
8条回答
  • 2020-12-20 13:15

    Cast it to integer, cast it back to varchar, and check that it equals the original string?

    0 讨论(0)
  • 2020-12-20 13:16

    Works in all versions:

    TRANSLATE(PROD_NUM,'123456789','000000000') = '000000000'
    
    0 讨论(0)
提交回复
热议问题