oracle基础:使用字符串
2015-04-21 19:33
106 查看
--提取字符 substr(字段,开始位置,提取字符个数) replace(字段,查找字符,被替换成的字符串)
select substr(b.book_author,1,1) as 作者的姓 from book b;
select replace(b.book_name,'<<','') as 书名 from book b;
--使用正则表达式 regexp_replace(字段,正则表达式,被替换成的字符串) regexp_like(字段,正则表达式);
/* 注意:^ 字符串开始, $字符串结束 regexp_like(b.book_name,'^A'); 等价于 like 'A%' */
select regexp_replace(b.book_name,'\<<|\>>','') as 书名 from book b;
select * from book b where b.book_name like '%平凡的%';
select * from book b where regexp_like(b.book_name,'平凡的|孙子');
--分析函数listagg(字段,'连接符')或者 wmsys.wm_concat(字段)的运用
select deptno as 部门编号,
sum(sal) as 工资合计,
wmsys.wm_concat(ename) as 部门全部员工姓名
from emp group by deptno;
--将ip地址分离
select regexp_substr(v.ip,'[^.]+',1,1) a,
regexp_substr(v.ip,'[^.]+',1,2) b,
regexp_substr(v.ip,'[^.]+',1,3) c,
regexp_substr(v.ip,'[^.]+',1,4) d
from (select '192.168.1.110' as ip from dual) v;
select substr(b.book_author,1,1) as 作者的姓 from book b;
select replace(b.book_name,'<<','') as 书名 from book b;
--使用正则表达式 regexp_replace(字段,正则表达式,被替换成的字符串) regexp_like(字段,正则表达式);
/* 注意:^ 字符串开始, $字符串结束 regexp_like(b.book_name,'^A'); 等价于 like 'A%' */
select regexp_replace(b.book_name,'\<<|\>>','') as 书名 from book b;
select * from book b where b.book_name like '%平凡的%';
select * from book b where regexp_like(b.book_name,'平凡的|孙子');
--分析函数listagg(字段,'连接符')或者 wmsys.wm_concat(字段)的运用
select deptno as 部门编号,
sum(sal) as 工资合计,
wmsys.wm_concat(ename) as 部门全部员工姓名
from emp group by deptno;
--将ip地址分离
select regexp_substr(v.ip,'[^.]+',1,1) a,
regexp_substr(v.ip,'[^.]+',1,2) b,
regexp_substr(v.ip,'[^.]+',1,3) c,
regexp_substr(v.ip,'[^.]+',1,4) d
from (select '192.168.1.110' as ip from dual) v;
相关文章推荐
- ASP.NET基础问题----使用随机字符串
- Oracle基础学习四:字符串 数字 日期 等 相关函数
- Oracle基础学习四:字符串 数字 日期 等 相关函数
- Oracle基础知识---Oracle中 Alter Table 语句的使用
- oracle 使用存储过程分割字符串为数组
- Oracle SQLPlus 一些使用经验记录(设置环境变量和字符串比较)
- 使用Oracle可传输表空间的特性复制数据(1)基础概念
- oracle 字符串处理instr()函数使用
- Oracle字符串中使用单引号
- 在Oracle中使用字符串数组参数
- oracle 列别名 使用 双引号 特殊字符 区分 大小写 连接 运算符 字符串 || 双竖线
- oracle中使用split拆分字符串,并且判断字符串是否在数据库中存在
- oracle基础笔记-如果不是DBA,作为一个程序设计人员,特别是要使用Oracle的程序人员.非常有必要了解以下
- oracle字符串转日期格式,to_date()函数的使用
- oracle 连接运算符,连接字符串,||双竖线,在列别名上使用双引号,使用带有特殊字符的列别名
- oracle service 的创建、使用-基础分析
- Oracle字符串连接的使用方法
- 动态传入的逗号连接的字符串,分散成多条记录(Oracle 10g 使用REGEXP_SUBSTR 分拆字符串)
- 使用 Oracle 数据库 10g内部的 ETL 基础架构
- (转)oracle 连接运算符,连接字符串,||双竖线,在列别名上使用双引号,使用带有特殊字符的列别名