我创建了一个带分区的表:
CREATE TABLE edw_src.pageviewlog_dev
(
accessurl character varying(1000),
msisdn character varying(1000),
customerid integer
)
WITH (
OIDS=FALSE
)
DISTRIBUTED BY (msisdn)
PARTITION BY RANGE(customerid)
(
PARTITION customerid START (0) END (200)
)
现在我想将accessurl的数据量从1000更改为3000.我无法更改数据量,每当我尝试时,我都会收到错误。
错误:“pageviewlog_dev_1_prt_customerid”是分区配置的成员
提示:在主表上执行操作。
我可以更改如果我从pg_attribute更改数据类型。如果有任何其他方法来更改现有列的数据大小而不是pg_attribute
我已经找到了同样的解决方案。很晚才回复。只要我们在“Post grel and greenplum”中遇到这类问题,就可以这样做了。
UPDATE pg_attribute SET atttypmod = 300+4
WHERE attrelid = 'edw_src.ivs_hourly_applog_events'::regclass
AND attname = 'adtransactionid';
答案 0 :(得分:0)
管理员指南具有更改列数据类型的语法,您只需这样做:
ALTER TABLE edw_src.pageviewlog_dev
ALTER COLUMN accessurl TYPE character varying(3000);
以下是您的表格的工作示例:
CREATE SCHEMA edw_src;
CREATE TABLE edw_src.pageviewlog_dev
(
accessurl character varying(1000),
msisdn character varying(1000),
customerid integer
)
WITH (
OIDS=FALSE
)
DISTRIBUTED BY (msisdn)
PARTITION BY RANGE(customerid)
(
PARTITION customerid START (0) END (200)
);
输出:
NOTICE: CREATE TABLE will create partition "pageviewlog_dev_1_prt_customerid" for table "pageviewlog_dev"
Query returned successfully with no result in 47 ms.
现在改变表格:
ALTER TABLE edw_src.pageviewlog_dev
ALTER COLUMN accessurl TYPE character varying(3000);
输出:
Query returned successfully with no result in 62 ms.
psql中的证明:
\d edw_src.pageviewlog_dev
Table "edw_src.pageviewlog_dev"
Column | Type | Modifiers
------------+-------------------------+-----------
accessurl | character varying(3000) |
msisdn | character varying(1000) |
customerid | integer |
Number of child tables: 1 (Use \d+ to list them.)
Distributed by: (msisdn)
如果您无法更改表,可能是因为直接更新pg_attribute后目录已损坏。您可以尝试删除表并重新创建它,也可以打开支持票,让他们尝试纠正目录损坏。