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

来源:互联网 发布:ubuntu vi不保存退出 编辑:程序博客网 时间:2024/05/07 17:05

oracle并没有给我们提供这样一个现成的函数:
可行的做法:

方法1 使用trim+translate函数:

select * fromwhere trim(translate(字段,'0123456789',' ')) is not NULL;

方法2 使用regexp_like函数:

select * fromwhere 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’即可;

0 0