时间:2021-07-01 10:21:17 帮助过:16人阅读
--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