substring ,该函数用来求一个字符串的字串,该函数的使用频率很高。
示例字符串:”2011-11-17”
在Oracle中求字符串的函数为:substr
substr( string, start_position, [ length ] )
string:源字符串
start_position:子串第一个字符在源字符串中的起始位置
length:子串长度
测试结果:
1. substr('2011-11-17',0,7) 2011-11 2. substr('2011-11-17',1,7) 2011-11 3. substr('2011-11-17',1,10) 2011-11-17 4. substr('2011-11-17',1,11) 2011-11-17 5. substr('2011-11-17',-1,7) 7 6. substr('2011-11-17',-8,8) 11-11-17 7. substr('2011-11-17',-10,7) 2011-11 8. substr('2011-11-17',-11,7) null 9. substr('2011-11-17',-11) null 10. substr('2011-11-17',-1) 7 11. substr('2011-11-17',6) 11-17 12. substr('2011-11-17',11) null 13. substr (‘2011-11-17’,1,null) null 14. substr (‘2011-11-17’,null,1) null 15. substr (‘2011-11-17’,null,null) null 16. substr ('2011-11-17',1,0) null 17. substr ('2011-11-17',1,-1) null 18. substr ('2011-11-17',11,11) null
Oracle中规定:
1) start_position==0时,子串的起始位置为1,即从第一个字符开始;
2) start_position<0时,字串的起始位置从字符串尾部开始后推。
3) length参数可以缺省。
相关推荐
oracle中 substring函数的使用
9、说明:in 的使用方法 select * from table1 where a [not] in (‘值1’,’值2’,’值4’,’值6’) 10、说明:两张关联表,删除主表中已经在副表中没有的信息 delete from table1 where not exists ( select * ...
当前数据库中必须有CTXSYS用户和CTXAPP角色 * 2008/10/17 yanjianzhong ******************************************/ /*1、使用具有sysdba权限的用户登录/ grant connect,resource to portal; grant ctxapp...
获得数据库中表字段的名字 行转列附加.txt 连接字段输出.txt 遍历数据库.txt 50个常用sql语句.txt not exists用法实例.txt ORACLE编程实用手册.doc patindex的用法.txt rename存储过程.txt replace.txt rowcount...
) 代码如下: MySQL: SUBSTR( ), SUBSTRING( ) Oracle: SUBSTR( ) SQL Server: SUBSTRING( ) ; 常用的方式是: SBUSTR(str,pos); 就是从pos开始的位置,一直截取到最后。 还有一种比较常用的是: 代码如下: SUBSTR...
♦ SQL 指令: SQL 如何被用来储存、读取、以及处理数据库之中的资料。 ♦ 表格处理: SQL 如何被用来处理数据库中的表格。 ♦ 进阶 SQL: 介绍 SQL 进阶概念,以及如何用 SQL 来执行一些较复杂的运算。 ♦ SQL 语法: ...
mssql 2000 Access DB2 oracle 【mysql安装】 1、官方下载mysql win32 msi 2、点击安装 3、配置 4、查看是否安装成功 通过cmd 输入netstat -a搜索3306端口是否处于listening状态 【mysql服务的启动与停止】 1...
9、说明:in 的使用方法 select * from table1 where a [not] in (‘值1’,’值2’,’值4’,’值6’) 10、说明:两张关联表,删除主表中已经在副表中没有的信息 delete from table1 where not exists ( select * ...
9、说明:in 的使用方法 select * from table1 where a [not] in (‘值1’,’值2’,’值4’,’值6’) 10、说明:两张关联表,删除主表中已经在副表中没有的信息 delete from table1 where not exists ( select * ...
5、跨数据库函数方言替换,如:isnull/ifnull/nvl、substr/substring 等不同数据库。 sqltoy-orm特点: 1、最优雅直观的sql编写模式 2、天然防止sql注入,执行过程 3、最强大的分页查询 4、最巧妙的缓存应用,将多表...
MyBatis使用简单的XML或注解用于配置和原始映射,将接口和Java的POJOs(Plan Old Java Objects,普通的Java对象)映射成数据库中的记录. orm工具的基本思想 无论是用过的hibernate,mybatis,你都可以法相他们有一个...
379. Top-K Oracle: A New Way to Present Top-K Tuples for Uncertain Data Chunyao Song (University of Massachusetts, Lowell) Zheng Li (University of Massachusetts, Lowell) Tingjian Ge (University of ...
显示第一个语句中不在第二个语句中的项 [SQL 语句 1] MINUS [SQL 语句 2] (21) Concatenate................................... ............... ...............................12 结果相加(串联) MySQL/Oracle...