sql语句 怎么在一个字符串中间加几个字符
作者&投稿:成王策 (若有异议请与网页底部的电邮联系)
1、创建测试表,
create table test_split(id number, value varchar2(20));
2、插入测试数据
insert into test_split values(1,'12345678');
insert into test_split values(2,'12345');
insert into test_split values(2,'5678');
3、查询表中记录,select t.*, rowid from test_split t;
4、编写sql,每隔两位用:分割,
select t.*,
rtrim(substr(value, 1, 2) || ':' || substr(value, 3, 2) || ':' ||
substr(value, 5, 2) || ':' || substr(value, 7, 2),
':') value2
from test_split t;
~