【问题标题】:many to many intersection tables in amazon redshift亚马逊红移中的多对多交集表
【发布时间】:2013-04-24 13:49:08
【问题描述】:

在普通sql中做类似多对多基数表的最好方法是什么。

示例 - 三个表:Product(id identity, name varchar(max)), Sale(id identity,customer varchar(max)), SalesLine(id identity, product integer references product, sale integer references sale):

INSERT INTO Product (name) VALUES ('new product');
INSERT INTO Sale (customer) VALUES ('new customer');
INSERT INTO SaleLine(product, sale) VALUES(?,?);

在 postgresql 中,currval 之类的东西很有帮助,但在 amazon redshift 中不可用。

我在想也许还需要一些其他的范式?

【问题讨论】:

    标签: sql amazon-redshift


    【解决方案1】:

    AFAIK redshift 不支持插入返回/currval/类似的东西。你可以在亚马逊红移论坛https://forums.aws.amazon.com/thread.jspa?messageID=449390

    看到这个

    如果您有串行插入(不是来自多个线程),我的建议是不要使用 Identity 列,而是维护一个 pk 和一个高价值的 ref 表并自己指定 ID。

    P.S 这个解决方案也适用于并行插入,只是有点棘手。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-03
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 2013-05-26
      • 1970-01-01
      • 1970-01-01
      • 2013-06-01
      相关资源
      最近更新 更多