首页 > 解决方案 > 在单字节字符集环境中存储多字节字符 oracle 12c

问题描述

早些时候,我们将JSON包含最新10对话的内容存储NCLOB在数据库的列中以用于缓存目的。但现在我们必须以JSON格式存储所有对话并提供搜索功能。为了利用 oracle 的文本搜索,我们尝试使用BLOBdatatype 而不是NCLOB. 然而,我们面临着存储多字节字符和搜索它的问题。关于如何使用BLOB数据类型的任何建议?

这是我正在尝试的一个例子

--创建带有blob列的表--

create table departments_json (
  department_id   integer not null primary key,
  department_data blob not null
);

---添加JSON检查约束---

alter table departments_json
  add constraint dept_data_json 
  check ( department_data is JSON FORMAT JSON STRICT );

---------------用于文本搜索的索引 json 列-------

create index deptj_ctx_ix on departments_json (department_data) 
indextype is ctxsys.context parameters ('section group CTXSYS.JSON_SECTION_GROUP sync (on commit)');

--插入带有多字节字符的Json

insert into departments_json 
  values ( 100, utl_raw.cast_to_raw ('{"department_list":[{"Deptname":"DEPT-A", "value" : "məharaːʂʈrə"}]}'));

插入失败: ORA-02290:违反检查约束 (REGCOA_SPM.DEPT_DATA_JSON)

标签: oracleoracle12c

解决方案


推荐阅读