SQL 在 Oracle 中定义 CLOB 的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15844434/
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
Defining size of CLOB in Oracle
提问by Femme Fatale
I am making a table in which i am storing XML. To store XML i am using CLOB data type. The max size of my XML would be 5kb. What size of CLOB column should i define while creating the table?
我正在制作一个表格,我在其中存储 XML。为了存储 XML,我使用 CLOB 数据类型。我的 XML 的最大大小为 5kb。创建表时应该定义多大的 CLOB 列?
回答by DazzaL
you don't define a size exactly when setting a clob (unlike a varchar). it is just simply clob
.
您在设置 clob 时没有准确定义大小(与 varchar 不同)。这只是简单的clob
。
The max size of a lob is 4Gb.
一个 lob 的最大大小是 4Gb。
Storage wise it will use space as follows:
存储方面,它将按如下方式使用空间:
- if the lob is defined as in-row, and the lob is less than ~ 4kb , it will just take up the amount of space that the document is. (eg store an xml of 512 bytes in-row and it will use 512 bytes.
- if the lob is defined out of row (or exceeded 4kb) then it will use a multiple of the "chunk" size that you defined when creating the table.
- 如果 lob 被定义为行内,并且 lob 小于 ~ 4kb ,它只会占用文档的空间量。(例如,在行中存储 512 字节的 xml,它将使用 512 字节。
- 如果 lob 是在行外定义的(或超过 4kb),那么它将使用您在创建表时定义的“块”大小的倍数。
when creating a lob column, you can specify its storage clause to control in-row and out-of-row options like this:
创建 lob 列时,您可以指定其存储子句来控制行内和行外选项,如下所示:
LOB (c) STORE AS lobseg (DISABLE STORAGE IN ROW CHUNK 16384)
i.e. that would specify that the lob can never be stored inline with the regular table data, and will allocate storage in multiples of 16kb per chunk, so even if your document was 1kb, it would take 16kb of storage.
即,这将指定 lob 永远不能与常规表数据内联存储,并且将以每个块 16kb 的倍数分配存储,因此即使您的文档是 1kb,它也会占用 16kb 的存储空间。
if your xml documents are only 5kb, you may want to consider in-row storage, and put a small chunk size (the min chunk size is 1 block, so if you have a tablespace with 4kb extents, your minumum chunk size will be 4kb; if you specify less, it will be ignored). the disadvantage of allowing in-row lobs, is that the table will be larger, so large range scans may suffer a bit (but lob retrieval is faster).
如果您的 xml 文档只有 5kb,您可能需要考虑行内存储,并放置一个小块大小(最小块大小为 1 个块,因此如果您有一个 4kb 范围的表空间,您的最小块大小将是 4kb ; 如果你指定的更少,它将被忽略)。允许行内 lob 的缺点是表会更大,因此大范围扫描可能会受到一些影响(但 lob 检索更快)。
Also in 11g you have the option to compress lob segments which you may want to consider (if your licence covers it). Though with such small documents you may not benefit greatly.
同样在 11g 中,您可以选择压缩您可能想要考虑的 lob 段(如果您的许可证涵盖它)。尽管使用如此小的文档,您可能不会受益匪浅。
read more here : http://docs.oracle.com/cd/B28359_01/appdev.111/b28393/adlob_tables.htm
在此处阅读更多信息:http: //docs.oracle.com/cd/B28359_01/appdev.111/b28393/adlob_tables.htm