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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ascii码chr,chr(10),chr(13)在oracle中的用法相关的知识,希望对你有一定的参考价值。

--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,chr(10),chr(13)在oracle中的用法的主要内容,如果未能解决你的问题,请参考以下文章

Oracle chr() ascii()

Oracle中chr()函数

在oracle里如何去掉数据后的回车换行符

python用random产生验证码

python如何将ascii码转换为字母

在oracle里如何去掉数据后的回车换行符