判断Oracle中某个字段是否含有数字


select * from gy_jbbm where regexp_substr(jbmc,'[0-9]+') is not null

 

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

脚本:
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
————————————————
版权声明:本文为CSDN博主「pengShuai007」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/pengShuai007/article/details/83031973

原文地址:https://www.cnblogs.com/thomasbc/p/10952033.html