简体   繁体   中英

Is it possible to update one table from another table without a join in Vertica?

I have two tables A(i,j,k) and B(m,n).

I want to update the 'm' column of B table by taking sum(j) from table A. Is it possible to do it in Vertica?

Following code can be used for Teradata, but does Vertica have this kind of flexibility?

Update B from (select sum(j) as m from A)a1 set m=a1.m;

Teradata SQL语法不适用于Vertica,但以下查询应做同样的事情:

update B set m = (select sum(j) from A)

Depending on the size of your tables, this may not be an efficient way to update data. Vertical is a WORM (write once read many times) store, and is not optimized for updates or deletes.

An alternate way would be to first temporarily move the data in the target table to another intermediate (but not temporary) table. After that write a join query using the other table to produce the desired result, and finally use export table with that join query. Finally drop the intermediate table. Of course, this is assuming you have partitioned your table in a way suitable for your update logic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM