Oracle中判断字段是否为数字(能转化为正整数)
2016-12-05 15:19
411 查看
oracle并没有给我们提供这样一个现成的函数:
可行的做法:
方法1 使用trim+translate函数:
方法2 使用regexp_like函数:
方法23 使用regexp_replace函数:
select count(1) from ns_organization where regexp_replace(deptcode,’\d’,”) is not null;
以上代码是取出非正整数数据,相反则去掉‘not’即可;
可行的做法:
方法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’即可;
相关文章推荐
- oracle逻辑结构和物理结构
- Oracle Cursor
- oracle 批量更新
- ORACLE常用系统视图(整理)
- Oracle中imp、exp命令的使用
- Oracle SQL中的IN 和 EXSITS区别总结
- truncate和delete的区别
- oracle的concat的用法
- oracle connect by用法篇
- 查询Oracle正在执行的sql语句
- oracle创建DBLINK
- rails gem 安装oci8 oracle数据库驱动
- oracle存储过程中文乱码问题
- Oracle12c安装后忘记用户名和密码可通过如下方法解决:
- oracle的物理存储结构
- oracle dg中角色切换后的序列测试
- oracle dblink
- Oracle学习一
- oracle导入TYPE对象报错ORA-02304
- Java 连接oracle 的maven配置