有人可以解释下面的行为
KAP.ADMIN(ADMIN)=> create table char1 ( a char(64000),b char(1516));
CREATE TABLE
KAP.ADMIN(ADMIN)=> create table char2 ( a char(64000),b char(1517));
错误:65536:超出记录大小限制
KAP.ADMIN(ADMIN)=> insert into char1 select * from char1;
错误:65540:超出记录大小限制=>为什么这个错误期间 如果create table不为同一个表抛出任何错误,则插入 如上所示。
KAP.ADMIN(ADMIN)=> \d char1
Table "CHAR1"
Attribute | Type | Modifier | Default Value
-----------+------------------+----------+---------------
A | CHARACTER(64000) | |
B | CHARACTER(1516) | |
Distributed on hash: "A"
./nz_ddl_table KAP char1
Creating table: "CHAR1"
CREATE TABLE CHAR1
(
A character(64000),
B character(1516)
)
DISTRIBUTE ON (A)
;
/*
Number of columns 2
(Variable) Data Size 4 - 65520
Row Overhead 28
====================== =============
Total Row Size (bytes) 32 - 65548
*/
我想知道上面案例中行大小的计算。 我检查了netezza db用户指南,但在上面的例子中无法理解它的计算。
答案 0 :(得分:0)
首先根据一行数据创建一个临时表。
create temp table tmptable as
select *
from Table
limit 1
然后检查临时表的已用字节。那应该是每行的大小。
select used_bytes
from _v_sys_object_storage_size a inner join
_v_table b
on a.tblid = b.objid
and b.tablename = 'tmptable'
Netezza有一些限制: 1)char / varchar字段中的最大字符数:64,000 2)最大行大小:65,535字节
新西兰的记录长度超过65 k字节是不可能的。 虽然新西兰的箱子提供了巨大的空间,但是准确的空间预测以及相当宽敞的间距进行移动是个不错的主意。现在,在您的要求中,所有属性都强制要求char(64000)或者可以通过实时数据分析进行压缩。如果可以进一步压缩,则重新访问属性长度。 在这样的要求期间,永远不要使用insert到char1 select * .......语句,因为这将允许系统选择首选数据类型,并且可能没有必要使用更高的大小。
答案 1 :(得分:0)
我认为这个链接可以很好地解释Netezza / PDA数据类型的问题:
For every row of every table, there is a 24-byte fixed overhead of the rowid, createxid, and deletexid. If you have any nullable columns, a null vector is required and it is N/8 bytes where N is the number of columns in the record.
The system rounds up the size of
this header to a multiple of 4 bytes.
In addition, the system adds a record header of 4 bytes if any of the following is true:
Column of type VARCHAR
Column of type CHAR where the length is greater than 16 (stored internally as VARCHAR)
Column of type NCHAR
Column of type NVARCHAR
Using UTF-8 encoding, each Unicode code point can require 1 - 4 bytes of storage. A 10-character string requires 10 bytes of storage if it is ASCII and up to 20 bytes if it is Latin, or as many as 40 bytes if it is Kanji.
The only time a record does not contain a header is if all the columns are defined as NOT NULL, there are no character data types larger than 16 bytes, and no variable character data types.