我们拥有三个数据库:开发、登台和生产。我们在开发环境中完成所有编码。然后,我们将所有代码和数据库更改推送到暂存阶段,以便客户可以看到它在实时环境中的工作原理。在他们签字后,我们将最终部署到生产环境。
现在,关于这些 CLOB 列:当使用 desc 和/或查询 dev 数据库的 all_tab_columns 视图时,CLOB 显示的数据长度为 4,000。然而,在登台和生产数据库中,开发等效 CLOB 列的数据长度是奇数,例如 86。我已经搜索了所有可能的解决方案来了解这是如何实现的。我什至尝试添加一个新的 CLOB(86) 列,认为它会像 VARCHAR2 一样工作,但 Oracle 只是吐出一个错误。
DBA 是否搞砸了一些事情?这还值得担心吗?似乎没有因此而破坏任何东西,但我只是希望元数据在所有环境中都相同。
We have three databases: dev, staging, and production. We do all our coding in the dev environment. We then push all our code and database changes to staging so the client can see how it works in a live environment. After they sign off, we do the final deployment to the production environment.
Now, about these CLOB columns: When using desc and/or querying the all_tab_columns view for the dev database, CLOBs show a data length of 4,000. However, in the staging and production databases, data lengths for dev-equivalent CLOB columns are odd numbers like 86. I've searched for every possible solution as to how this could have come about. I've even tried adding a new CLOB(86) column thinking it would work like it does for VARCHAR2, but Oracle just spits out an error.
Could the DBAs have botched something up? Is this even something to worry about? Nothing has ever seemed to break as a result of this, but I just like the metadata to be the same across all environments.
发布评论
评论(4)
首先,作为一名 dba,我对您和 dba 之间缺乏合作感到遗憾。我们都需要合作才能成功。 Clob 数据长度可以小于 4000 字节。
哪里发现clob长度不能小于4000?
First of all, I - as a dba - feel sorry to see the lack of cooperation between you and the dbas. We all need to cooperate to be successful. Clob data lengths can be less than 4000 bytes.
Where do you find that a clob length can not be less than 4000?
DATA_LENGTH 存储行中列所占用的最大字节数。如果 CLOB 可以按行存储,则最大为 4000。LOBS 永远不会占用超过 4000 字节。如果禁用行存储,则 LOB 将仅存储查找 LOB 数据所需的指针信息,该信息远小于 4000 字节。
编辑,在 *_LOBS 视图上添加信息
使用 [DBA|ALL|USER]_LOBS 视图查看定义的行外存储设置:
编辑 2,一些参考
请参阅 中的 rel="nofollow">LOB 存储 Oracle 数据库应用程序开发人员指南 - 大对象了解有关定义 LOB 存储的更多信息,尤其是讨论可以更改的内容的第三条注释:
另外,索引组织表中的 LOB说:
这解释了为什么 jonearles 在索引组织表中创建 LOB 时在 data_length 列中没有看到 4,000。
DATA_LENGTH stores the maximun # of bytes that will be taken up within the row for a column. If the CLOB can be stored in row, then the maximum is 4000. LOBS will never take up more than 4000 bytes. If in row storage is disabled, then the LOB will only store the pointer information it needs to find the LOB data, which is much less than 4000 bytes.
EDIT, adding info on *_LOBS view
Use the [DBA|ALL|USER]_LOBS view to look at the defined in row out of row storage settings:
EDIT 2, some references
See LOB Storage in Oracle Database Application Developer's Guide - Large Objects for more information on defining LOB storage, especially the third note that talks about what can be changed:
Also, LOBs in Index Organized Tables says:
This explains why jonearles did not see 4,000 in the data_length column when he created the LOB in an index organized table.
CLOB 没有指定的长度。当您查询 ALL_TAB_COLUMNS 时,例如:
您会注意到 data_length 始终为 4000,但这应该被忽略。
CLOB 的最小大小为零 (0),最大大小为 8 TB 到 128 TB 之间的任意值,具体取决于数据库块大小。
CLOBs don't have a specified length. When you query ALL_TAB_COLUMNS, e.g.:
You'll notice that data_length is always 4000, but this should be ignored.
The minimum size of a CLOB is zero (0), and the maximum is anything from 8 TB to 128 TB depending on the database block size.
正如 ik_zelf 和 Jeffrey Kemp 指出的,CLOB 可以存储少于 4000 字节。
但为什么 CLOB data_lengths 不总是 4000?该数字实际上并不限制 CLOB,但您担心元数据可能是正确的
在您的服务器上有所不同。您可能希望对所有服务器上的对象运行 DBMS_METADATA.GET_DDL 并比较结果。
我能够通过向索引组织表添加 CLOB 来创建低 data_length。
在 10.2.0.1.0 上,结果是 116。
在 11.2.0.1.0 上,结果是 476。
这些数字对我来说没有任何意义,我猜这是一个错误。但我对不同的存储选项不太了解,也许我只是错过了一些东西。
有人知道这里到底发生了什么吗?
As ik_zelf and Jeffrey Kemp pointed out, CLOBs can store less than 4000 bytes.
But why are CLOB data_lengths not always 4000? The number doesn't actually limit the CLOB, but you're probably right to worry about the metadata being
different on your servers. You might want to run DBMS_METADATA.GET_DDL on the objects on all servers and compare the results.
I was able to create a low data_length by adding a CLOB to an index organized table.
On 10.2.0.1.0, the result is 116.
On 11.2.0.1.0, the result is 476.
Those numbers don't make any sense to me and I'd guess it's a bug. But I don't have a good understanding of the different storage options, maybe I'm just missing something.
Does anybody know what's really going on here?