SQL dbms_lob.getlength() 与 length() 在 oracle 中查找 blob 大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2373138/
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-01 05:34:26  来源:igfitidea点击:

dbms_lob.getlength() vs. length() to find blob size in oracle

sqloracleblob

提问by Vincent Malgrat

I'm getting the same results from

我得到了相同的结果

select length(column_name) from table

as

作为

select dbms_lob.getlength(column_name) from table

select dbms_lob.getlength(column_name) from table

However, the answers to this questionseem to favor using dbms_lob.getlength().

然而,这个问题的答案 似乎倾向于使用dbms_lob.getlength().

Is there any benefit to using dbms_lob.getlength()?

使用有什么好处dbms_lob.getlength()吗?

If it changes the answer, I know all of the blobs are .bmp images (never worked with blobs before).

如果它改变了答案,我知道所有的 blob 都是 .bmp 图像(以前从未使用过 blob)。

回答by Vincent Malgrat

lengthand dbms_lob.getlengthreturn the number of characters when applied to a CLOB(Character LOB). When applied to a BLOB(Binary LOB), dbms_lob.getlengthwill return the number of bytes, which may differ from the number of characters in a multi-byte character set.

lengthdbms_lob.getlength返回应用于CLOB(字符 LOB)时的字符数。当应用于BLOB(二进制 LOB)时,dbms_lob.getlength将返回字节数,这可能与多字节字符集中的字符数不同。

As the documentation doesn't specify what happens when you apply lengthon a BLOB, I would advise against using it in that case. If you want the number of bytes in a BLOB, use dbms_lob.getlength.

由于文档没有具体说明申请lengthBLOB时会发生什么,我建议不要在这种情况下使用它。如果您想要 BLOB 中的字节数,请使用dbms_lob.getlength.