oracle 将 clob 转换为 varchar2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2701436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:29:24  来源:igfitidea点击:

convert clob to varchar2

sqloracle

提问by Shamik

I have a Oracle table whose column is a CLOB datatype. I want to read the content of this table as a text.

我有一个 Oracle 表,其列是 CLOB 数据类型。我想以文本形式阅读此表的内容。

I tried select dbms_lob.substr( sqltext, 4000, 1 ) from testbut this one selects only the first 4000 bytes. How to read the entire content ? there are more than 4000 characters in the sqltext column. Please advise.

我试过了, select dbms_lob.substr( sqltext, 4000, 1 ) from test但这个只选择前 4000 个字节。如何阅读全部内容?sqltext 列中有 4000 多个字符。请指教。

采纳答案by Fazal

If you are using another language like Java to read the data, JDBC drivers provide ways to read CLob and Blob columns.

如果您使用另一种语言(如 Java)读取数据,JDBC 驱动程序提供了读取 CLob 和 Blob 列的方法。

For using a direct SQL query on a SQL client to read such columns, it wont work out of the box as clob and blob values greater than 4000 bytes have to be read using a stream. You need to write PL/SQL to do this. Here is one useful link you can look at

对于在 SQL 客户端上使用直接 SQL 查询来读取此类列,它不会开箱即用,因为必须使用流读取大于 4000 字节的 clob 和 blob 值。您需要编写 PL/SQL 来执行此操作。这是您可以查看的一个有用链接

http://www.dba-oracle.com/t_read_blob.htm

http://www.dba-oracle.com/t_read_blob.htm