Informix 表、索引对字段个数、长度的限制情况

来源:互联网 发布:openstack源码 编辑:程序博客网 时间:2024/05/18 15:57

 

Informix 表、索引对字段个数、长度的限制情况

 

1table

INFORMIX对表的单行大小最大限制为:32767 byte.对一般的数据类型的字段个数没有限制要求,只要行记录大小不超过32767 byte。比如,我们可以创建一个只有char(32)32 byte大小)一种数据类型的字段的话,我们可以一共创建

32767/32~=1000 个字段。

create table test_clumn(t1 lvarchar(32739))

 

但是对于varchar,lvarchar,nvarchar,blobtext类型的总个数限制,2K PAGE 195,对4K PAGE 344

 

Test:

create table test_column(t1 char(30000),t2 char(2767));

--ok

create table test_column(t1 char(30000),t2 char(2768));

--Error 行大小超过32767

 

 

2INDEX:

由于LVARCHAR需要额外的3byte,所以其实际大小比其他类型要少3byte

1/复合索引

 最多可以创建包含16个列(字段)的索引,但列的总共大小为390 byte(不包括Lvarchar)

 

2/lvarchar字段上索引键长度限制

 

不同数据页面大小对lvarchar类型字段支持的索引键大小有不同的限制

页面大小  最大索引键大小

2K        387 byte

4K        768 byte

8K        1615 byte

16K       3245 byte

这种限制意味着,如果我们把一个表的某一个字段的数据类型设置为lvarchar,同时我们需要在该字段上创建索引,我们就需要考虑采用更大的page size

或者采用char数据类型替代。

 

Test

CASE :2K PAGE size

create table test_index(C1 INTEGER,C2 INTEGER,C3 INTEGER,C4 INTEGER,C5 INTEGER,C6 INTEGER,C7 INTEGER,

C8 INTEGER,C9 INTEGER,C10 INTEGER,C11 INTEGER,C12 INTEGER,C13 INTEGER,C14 INTEGER,C15 INTEGER,C16 INTEGER,C17 INTEGER,

t1 char(390),

t2 char(391),

t3 lvarchar(387),

t4 lvarchar(388)

);

 

create index idx_test_index1 on test_index( C1 ,C2,C3,C4,

C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16

);

--OK

create index idx_test_index2 on test_index( C1 ,C2,C3,C4,

C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17

);

--error 索引列个数超过16

 

create index idx_test_index3 on test_index(t1);

--ok

 

create index idx_test_index4 on test_index(t2);

--error 索引列大小超过390 byte

 

create index idx_test_index5 on test_index(t3);

--OK

 

create index idx_test_index6 on test_index(t4);

--error 索引列(lvarchar类型)大小超过387

 

Test

CASE :4K PAGE size

create table test_index_4k(C1 INTEGER,C2 INTEGER,C3 INTEGER,C4 INTEGER,C5 INTEGER,C6 INTEGER,C7 INTEGER,

C8 INTEGER,C9 INTEGER,C10 INTEGER,C11 INTEGER,C12 INTEGER,C13 INTEGER,C14 INTEGER,C15 INTEGER,C16 INTEGER,C17 INTEGER,

t1 char(799),

t2 char(800),

t3 lvarchar(796),

t4 lvarchar(797)

)in dbs_4k;

 

create index idx_test_index_4k1 on test_index_4k( C1 ,C2,C3,C4,

C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16

);

--OK

create index idx_test_index_4k2 on test_index_4k( C1 ,C2,C3,C4,

C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17

);

--error 索引列个数超过16

 

create index idx_test_index_4k3 on test_index_4k(t1);

--ok

 

create index idx_test_index_4k4 on test_index_4k(t2);

--error 索引列大小超过799 byte

 

create index idx_test_index_4k5 on test_index_4k(t3);

--OK

 

create index idx_test_index_4k6 on test_index_4k(t4);

--error 索引列(lvarchar类型)大小超过796