码迷,mamicode.com
首页 > 数据库 > 详细

ascii码chr(9),chr(10),chr(13)在oracle中的用法

时间:2017-06-05 16:46:16      阅读:572      评论:0      收藏:0      [点我收藏+]

标签:str   oracle   天津   ble   平谷   mit   怀柔区   插入数据   ora   

--1 建表

create table city_table
(
city_name varchar2(100)
,District varchar2(100)
);

--2 插入数据

insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘东城区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘西城区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘崇文区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘宣武区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘朝阳区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘海淀区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘丰台区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘石景山区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘门头沟区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘房山区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘通州区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘顺义区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘昌平区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘大兴区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘怀柔区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘平谷区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘密云县‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘北京‘, ‘延庆县‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘河东区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘河西区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘南开区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘河北区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘红桥区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘塘沽区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘汉沽区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘大港区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘东丽区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘西青区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘北辰区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘津南区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘武清区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘宝坻区‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘静海县‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘宁河县‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘蓟县‘);
insert into CITY_TABLE (CITY_NAME, DISTRICT)values (‘天津‘, ‘和平区‘);

commit;

--进击吧

select city_name,wm_concat(District||chr(10))
from city_table
group by city_name;

--结果发现,里面的子信息会按照一行一行的方式进行排列(chr(13),chr(10))

chr(9)的作用是空格

ascii码chr(9),chr(10),chr(13)在oracle中的用法

标签:str   oracle   天津   ble   平谷   mit   怀柔区   插入数据   ora   

原文地址:http://www.cnblogs.com/88893636-xuyang/p/6945469.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!