Oracle截取某字段前后字符串

创建测试表及数据

1
2
3
4
5
6
7
8
9
create table test
(name varchar2(10));
 
insert into test values ('2-15');
insert into test values ('2-33');
insert into test values ('2-3');
insert into test values ('12-8');
insert into test values ('12-22');
insert into test values ('12-3');

 

 执行

1
select name,substr(name,1,instr(name,'-')-1) 前,substr(name,instr(name,'-')+1,length(name)-instr(name,'-')) 后 from test
 

posted on 2016-09-09 12:10  生生卡卡的生生  阅读(8363)  评论(0编辑  收藏  举报

导航