[英]Exasol UPSERT without using a second table?
I could not find anything online about this problem.我在网上找不到有关此问题的任何信息。 It seems ORACLE has a similar issue, which is handled using DUAL
, as suggested in this StackOverflow answer .似乎 ORACLE 有一个类似的问题,这是使用DUAL
处理的,正如StackOverflow answer中所建议的那样。
But how do we do the same in Exasol?但是我们如何在 Exasol 中做同样的事情呢? According to their documentation , you need to MERGE
using a secondary table.根据他们的文档,您需要使用辅助表进行MERGE
。
I tried to do the same approach as on Oracle, to no avail:我尝试采用与 Oracle 相同的方法,但无济于事:
MERGE INTO TEST.TABLE USING SYS.DUAL ON "COLUMN_1" = "foo"
WHEN MATCHED THEN UPDATE SET "COLUMN_2" = "quux"
WHEN NOT MATCHED THEN INSERT ("COLUMN_1", "COLUMN_2") VALUES ("foo", "bar")
[2021-12-15 11:22:47] [0A000] Feature not supported: Merge using a system table as source that is no view. (Session: 1719203050222845952)
Is it not possible to UPSERT
like in other RDBMSs?不能像在其他 RDBMS 中一样进行UPSERT
吗?
You can rewrite the query like this:您可以像这样重写查询:
MERGE INTO TEST.TABLE
USING (select 'foo' as s) s ON COLUMN_1 = s
WHEN MATCHED THEN UPDATE SET COLUMN_2 = 'quux'
WHEN NOT MATCHED THEN INSERT (COLUMN_1, COLUMN_2) VALUES ('foo', 'bar')
This way you will eliminate DUAL table and keep correct join clause.这样您将消除 DUAL 表并保持正确的连接子句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.