oracle判断某一字段不是纯数字

时间:2025-03-09 15:11:46

背景:

表中某一字段中应该为纯数字,偶然发现该字段包含其他值,故,需要对不是纯数字的数据项进行过滤

脚本:

select distinct sub_account_item
  from pay_transaction_detail
 where trim(translate(sub_account_item, '0123456789', ' ')) is not null

解释:

translate函数将数据列sub_account_item中的数据替换为‘ ’,注意此处必须有空格,否则过滤不生效。

如果要过滤纯数字项,则将is not null改为is null