Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql amazon红移中的多对多交叉表_Sql_Amazon Redshift - Fatal编程技术网

Sql amazon红移中的多对多交叉表

Sql amazon红移中的多对多交叉表,sql,amazon-redshift,Sql,Amazon Redshift,如何在普通sql中执行类似于多对多基数表的操作是最好的方法 示例-三个表:产品(id标识,名称varchar(max)),销售(id标识,客户varchar(max)),销售线(id标识,产品整数引用产品,销售整数引用销售): 在postgresql中,类似于currval的内容很有用,但在amazon redshift中不可用 我在想,也许还需要一些其他的范例?AFAIK redshift不支持insert returning/currval/类似的东西。你可以在亚马逊红移论坛上看到这一点 如

如何在普通sql中执行类似于多对多基数表的操作是最好的方法

示例-三个表:产品(id标识,名称varchar(max)),销售(id标识,客户varchar(max)),销售线(id标识,产品整数引用产品,销售整数引用销售):

在postgresql中,类似于
currval
的内容很有用,但在amazon redshift中不可用


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

AFAIK redshift不支持insert returning/currval/类似的东西。你可以在亚马逊红移论坛上看到这一点

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

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

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