您的位置:首页 > 数据库 > Oracle

Oracle中判断字段是否为数字(能转化为正整数)

2016-12-05 15:19 411 查看
oracle并没有给我们提供这样一个现成的函数:

可行的做法:

方法1 使用trim+translate函数:

select * from 表 where trim(translate(字段,'0123456789',' ')) is not NULL;


方法2 使用regexp_like函数:

select * from 表 where not regexp_like(字段,'^\+?[1-9][0-9]*$');


方法23 使用regexp_replace函数:

select count(1) from ns_organization where regexp_replace(deptcode,’\d’,”) is not null;

以上代码是取出非正整数数据,相反则去掉‘not’即可;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: