博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
oracle数据库查询clob字段(Querying oracle clob column)
阅读量:6037 次
发布时间:2019-06-20

本文共 1346 字,大约阅读时间需要 4 分钟。

hot3.png

工作中遇到此场景,google查询到stackoverflow上的讨论,得到解答,使用内置函数dbms_lob.compare。讨论如下:

Question:

I have a table with a clob column. Searching based on the clob column content needs to be performed. However

select * from aTable where aClobColumn = 'value';

fails but

select * from aTable where aClobColumn like 'value';

seems to workfine. How does oracle handle filtering on a clob column. Does it support only the  'like' clause and not the =,!= etc. Is it the same with other databases like mysql, postgres etc

Also how is this scenario handled in frameworks that implement JPA like hibernate ?

Answer: 

Yes, it's not allowed (this restriction does not affectCLOBs comparison in PL/SQL)

to use comparison operators like=,!=,<>and so on in SQL statements, when trying

to compare twoCLOBcolumns orCLOBcolumn and a character literal, like you do. To be

able to do such comparison in SQL statements, function can be used.

select * from aTable where dbms_lob.compare(aClobColumn, 'value') = 0

In the above query, the'value'literal will be implicitly converted to theCLOBdata type.

To avoid implicit conversion, the'value'literal can be explicitly converted to theCLOB

data type usingTO_CLOB()function and then pass in to thecompare()function:

select * from aTable where dbms_lob.compare(aClobColumn, to_clob('value')) = 0

 

转载于:https://my.oschina.net/u/213148/blog/173985

你可能感兴趣的文章
ProtoBuffer 简单例子
查看>>
iOS多线程开发系列之(一)NSThread
查看>>
微信小程序初体验(上)- 腾讯ISUX社交用户体验设计成员出品
查看>>
SAP WM Physical Inventory Method ST & PZ
查看>>
一次快速的数据迁移感悟
查看>>
MySQL修改提示符
查看>>
《ELK Stack权威指南(第2版)》一3.6 Java日志
查看>>
C++流的streambuf详解及TCP流的实现
查看>>
《量化金融R语言初级教程》一2.5 协方差矩阵中的噪声
查看>>
mysql到elasticsearch数据迁移踩坑实践-Ali0th
查看>>
Python轻量级数据分析库DaPy
查看>>
beetl 和 shrio 结合
查看>>
相对/绝对路径,cd命令,mkdir/rmdir命令,rm命令
查看>>
tomcat中web.xml各配置项的意义
查看>>
Nodejs学习笔记(二):《node.js开发指南》代码中需要注意的几点
查看>>
Ztree异步加载自动展开节点
查看>>
反射操作公共成员变量
查看>>
Android热修复升级探索——代码修复冷启动方案
查看>>
学校宿舍的深夜之思考
查看>>
VB.NET 生成DBF文件
查看>>