oracle中文转换为unicode,oracle 用函数unistr将Oracle数据库中的Unicode转换为中文

用函数unistr将Oracle数据库中的Unicode转换为中文

1:保留连续的中文

select regexp_substr(‘Hello,大家好!greeting‘, ‘[‘ || unistr(‘\0391‘) || ‘-‘ || unistr(‘\9fa5‘) || ‘]+‘) from dual;

2:保留全部的中文

select regexp_replace(‘我爱你中国232、。,我爱你895‘, ‘[^‘ || unistr(‘\0391‘) || ‘-‘ || unistr(‘\9fa5‘) || ‘]‘,‘‘) from dual;

Oracle Unicode转中文(解码)

情景描述:

将数据库中的某个字段误存储的是Unicode编码,需要将其改成中文。

测试:

--将Unicode转中文

select unistr(REPLACE(‘\u6d4b\u8bd5unicode\u8f6c\u4e2d\u6587‘,‘\u‘,‘\‘)) from dual;

结果是:测试unicode转中文

实现:

--对某字段进行解码

update tableName set columnName = unistr(replace(columnName,‘\u‘,‘\‘));

封装:

/**

* unicode转中文

*/

CREATE OR REPLACE FUNCTION UNICODE2CHINESE(ENCODE_TEXT IN VARCHAR2)

RETURN VARCHAR2 IS

V_SQL VARCHAR2(10000); --编码转换sql

TEXT_BUFFER VARCHAR2(10000); --输出中文

BEGIN

V_SQL := ‘select unistr(REPLACE(‘‘‘ || ENCODE_TEXT ||

‘‘‘,‘‘\u‘‘,‘‘\‘‘)) from dual ‘;

EXECUTE IMMEDIATE V_SQL

INTO TEXT_BUFFER;

RETURN TEXT_BUFFER;

END;

oracle 用函数unistr将Oracle数据库中的Unicode转换为中文

标签:turn   oracl   media   保留   需要   into   create   函数   immediate

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉 本文系统来源:https://www.cnblogs.com/Melissa888/p/13097813.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Oracle SQL Developer, v1.5.0.54.40 Release Notes 完整版下载:http://www.oracle.com/technology/global/cn/software/products/sql/index.html 1. Known Issues 1.1 General - Print prints only one page that is a truncation of the current tab. - Can't invoke SQL*Plus on Windows 2003. - The menu item, and right-click off a Connection node, for invoking SQL*Plus does not work with connections whose passwords are not persisted. 1.2 Connections - Cannot connect to remote database as OPS$ account. 1.3 Browse - If connected as sys with sysdba role, Types node displays built in data-types (e.g. BLOB, DATE, DECIMAL, etc.) If clicked on, will only see "create or replace". 1.4 Creating and Modifying Objects - Editing Triggers - If you have comments before the 'BEGIN' they will be lost if you edit. You will see when you click edit that they will not be there. To preserve them, they need to be below the BEGIN or you will need to edit via the SQL Worksheet. 1.5 Table > Data - Tables > Your_Table > Data - PageUp and PageDown buttons not working correctly if cursor is in the rownum column. 1.6 Export - Cannot export if result set contains duplicate column names. 2. Workarounds 2.1 To disable Code Insight Run SQL Developer from a command line using the following statement: Windows : sqldeveloper -J-Dsdev.insight=false Linux or Mac: Run sh sqldeveloper -J-Dsdev.insight=false or edit sqldeveloper.conf and add "AddVMOption -J-Dsdev.insight=false" 2.2 If DDL tab is null for all objects in a Connection Your dbms_metadata might be loaded incorrectly. If this statement fails when executed in a SQL Worksheet against the Connection select dbms_metadata.get_ddl('TABLE',table_name , user ) from user_tables; You need to reload $ORACLE_HOME/rdbms/admin/catmeta.sql 2.3 If Snippets are not accessible You may have not done a clean install. SQL Developer needs to be installed into a clean directory, not over a previous release. 3. Accessibility Issues The following is a li

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值