为什么 MonetDB 不将此表添加到合并表中?

问题描述 投票:0回答:1

我正在努力处理合并表,需要社区帮助!

  1. 当我向新创建的合并表添加表时,“添加”的表是否需要为空?

  2. 如果“添加”表有一个标识列(定义为“monetdb”的 int next 值。“seq_nnnn”)合并表是否需要相应的列(序列怎么样?是相同的还是我必须创建一个新的?)

我尝试说得更具体。我创建了“正常”表

  1. “添加”表中的索引和约束怎么样?它们需要在合并表中复制吗?

我尝试了很多事情,但最终总是

SQL错误[3F000]:ALTER MERGE TABLE:要添加的表索引类型与MERGE TABLE定义不匹配

“正常”表是:

CREATE TABLE monetdb234234x.movcassa_m1 (
    idmov int NOT NULL,
    tipmov char(3) NOT NULL,
    nummov int NOT NULL,
    numsco int NOT NULL,
    datmov date NOT NULL,
    dataora timestamp NOT NULL,
    codmag char(2) NOT NULL,
    codcli char(7) NOT NULL,
    prezzosco decimal(12,5) DEFAULT '0' NOT NULL,
    CONSTRAINT movcassa_m1_idmov_pkey PRIMARY KEY (idmov)
);
CREATE INDEX movcassa_m1_datmov ON monetdb234234x.movcassa_m1 (datmov);
CREATE INDEX movcassa_m1_tipmov ON monetdb234234x.movcassa_m1 (tipmov);

然后我创建“合并”表:

CREATE merge TABLE monetdb234234x.movcassa_merge (
    idmov int NOT NULL,
    tipmov char(3) NOT NULL,
    nummov int NOT NULL,
    numsco int NOT NULL,
    datmov date NOT NULL,
    dataora timestamp NOT NULL,
    codmag char(2) NOT NULL,
    codcli char(7) NOT NULL,
    prezzosco decimal(12,5) DEFAULT '0' NOT NULL
);

然后我尝试添加表格:

alter TABLE monetdb234234x.movcassa_merge add table movcassa_m1

并得到错误:

SQL Error [3F000]: ALTER MERGE TABLE: to be added table key doesn't match MERGE TABLE definition

编辑:

如果我从第一个表中删除主索引子句,添加到合并表就会成功。但显然我需要表中的主键,因为我必须在该表中插入数据。

partitioning monetdb
1个回答
0
投票
  1. 添加到合并表(也称为子表)的表不必为空

  2. 我不确定您想在这里实现什么,但合并表的唯一约束是具有匹配的列类型(例如,合并表和子表之间不比较实际的列约束)。所以你可以做类似的事情

create table bar (n int, x text, idcol int default next value for barseq);
create table foo (m int, y text, idcol int default next value for fooseq);

create merge table foobar (l int, z text, idcol int);
alter table foobar add table bar;
alter table foobar add table foo;

当然,合并表的

idcol
列中不会有任何约束(例如唯一性)

  1. 它们不需要复制,并且在大多数情况下您将无法复制它们。您应该将合并表视为子表之间的 UNION ALL 视图。

有关合并(和合并分区)表使用的更多信息,此博文可能有用:https://www.monetdb.org/blogs/update-mergetables/

© www.soinside.com 2019 - 2024. All rights reserved.