Oracle 【to_number】【instr】
2016-05-25 18:48
459 查看
需求:对一个包含数字的字符串排序
search后参考了 http://www.cnblogs.com/m-cnblogs/archive/2012/03/30/2425938.html
截屏:
(用到了to_number(str,split 1,...) instr() replace() substr())
converts x to a
x is the string that will be converted to a number.
format, optional, is the format that will be used to convert x to a number.
nls_language, optional, is the nls language used to convert x to a number
INSTR(string, pattern-to-find)
The general syntax of INSTR is:
The arguments within brackets ([]) are optional.
在一个字符串中查找指定的字符,返回被查找到的指定的字符的位置。
如果start的值为负数,则代表从右往左进行查找,但是位置数据仍然从左向右计算。
从给定的字符表达式返回一个子字符串。
REPLACE(source-string, pattern-to-find, pattern-to-replace-by)
(to)‘2011-10-11’ ‘2011/10/11’ 转换
update 表1 t set t.列1=replace((select 列1from 表1 a where a.主键列=t.主键列) , '/' , '-' )
例:select replace ('111222333444','222','888') from dual;
输出为 '111888333444'
最后我的代码
pn
to_number(str,’-’)
str:
replace(source ,’-’)
source:
substr(pn,instr(pn,’-’)+1,
length(pn)-1-instr(pn,’-’))
search后参考了 http://www.cnblogs.com/m-cnblogs/archive/2012/03/30/2425938.html
截屏:
(用到了to_number(str,split 1,...) instr() replace() substr())
TO_NUMBER(x [, format], [ nls_language ])
converts x to a
NUMBER.
x is the string that will be converted to a number.
format, optional, is the format that will be used to convert x to a number.
nls_language, optional, is the nls language used to convert x to a number
INSTR(string, pattern-to-find)
INSTRreturns the location (beginning) of a pattern in a given string. Its simple form is:
The general syntax of INSTR is:
INSTR (string to search, search pattern [, start [,occurrence]])
The arguments within brackets ([]) are optional.
在一个字符串中查找指定的字符,返回被查找到的指定的字符的位置。
如果start的值为负数,则代表从右往左进行查找,但是位置数据仍然从左向右计算。
SUBSTRretrieves a portion of the string. The general format for this function is:
SUBSTR(string, start_at_position[, number_of_characters_to_retrieve])
从给定的字符表达式返回一个子字符串。
REPLACE(source-string, pattern-to-find, pattern-to-replace-by)
(to)‘2011-10-11’ ‘2011/10/11’ 转换
update 表1 t set t.列1=replace((select 列1from 表1 a where a.主键列=t.主键列) , '/' , '-' )
例:select replace ('111222333444','222','888') from dual;
输出为 '111888333444'
最后我的代码
pn
to_number(str,’-’)
str:
replace(source ,’-’)
source:
substr(pn,instr(pn,’-’)+1,
length(pn)-1-instr(pn,’-’))
相关文章推荐
- Oracle数据库——触发器的创建与应用
- Java 连接Oracle的问题
- PLSQL ORACLE 数据库解锁
- php查询oracle date时间
- 总结的新学的oracle数据库,适合学过的新手复习
- oracle数据库创建job,功能定时扫描表,更改状态值。比如定时每天晚上备份数据
- oracle编程
- 数据库-Oracle中的聚簇
- 【转】oracle调用外部java程序代码
- SQL Server和Oracle数据库索引介绍
- 数据库-Oracle主键约束和唯一索引的黑与白
- 数据库-Oracle中聚簇表的使用
- Oracle CTSS时间同步
- Oracle删除表、字段之前判断表、字段是否存在
- Oracle学习总结(8)—— 面向程序员的数据库访问性能优化法则
- Oracle学习总结(8)—— 面向程序员的数据库访问性能优化法则
- Oracle学习总结(8)—— 面向程序员的数据库访问性能优化法则
- JDBC调用oracle存储过程(返回单行,返回多行)
- Oracle的AWR报告分析
- Oracle 12c创建用户是出现“ORA-65096: invalid common user or role name”的错误