Postgres allows:

UPDATE dummy
SET customer=subquery.customer,
    address=subquery.address,
    partn=subquery.partn
FROM (SELECT address_id, customer, address, partn
      FROM  /* big hairy SQL */ ...) AS subquery
WHERE dummy.address_id=subquery.address_id;

This syntax is not standard SQL, but it is much more convenient for this type of query than standard SQL. I believe Oracle (at least) accepts something similar.

Answer from Andrew Lazarus on Stack Overflow
🌐
PostgreSQL
postgresql.org › docs › current › sql-update.html
PostgreSQL: Documentation: 18: UPDATE
May 14, 2026 - The sub-query must yield no more than one row when executed. If it yields one row, its column values are assigned to the target columns; if it yields no rows, NULL values are assigned to the target columns.
Discussions

Update fastest way
You could detach the partititions, do the update in separate sessions and reattach it later. Update in postgresql is basically a delete and an insert. Have you considered creating a completely new table with the data and copying the transformed data into it? Afterwards you just have drop the old table and rename the new one. More on reddit.com
🌐 r/PostgreSQL
12
4
September 14, 2024
Update column in a very large table (10M records)
I'd do the updates in batches of 1-10k max, and making sure that each update is in its own transaction. it will take long time, but it will not lock concurrent writes. More on reddit.com
🌐 r/PostgreSQL
37
1
June 5, 2024
postgresql - Update Oracle DB table from Postgres/PostGIS DB query - Geographic Information Systems Stack Exchange
I have an Oracle DB where Geolocation (Longitude, Latitude) data is storing. I want to update another column which is the neighborhood of that geolocation. Currently, I do not have oracle spatial s... More on gis.stackexchange.com
🌐 gis.stackexchange.com
April 8, 2018
[PostgreSQL] Update query not working
It sounds like the client is starting a transaction but not committing it. When the client is restarted, the database server rolls the changes back because it had not seen a commit command.. More on reddit.com
🌐 r/SQL
4
2
November 6, 2019
🌐
DB Vis
dbvis.com › thetable › the-postgres-update-statement-a-deep-dive
The Postgres UPDATE Statement: A Deep Dive
September 5, 2024 - Omit the WHERE clause in a Postgres UPDATE query to update every row in the table.
🌐
W3Schools
w3schools.com › postgresql › postgresql_update.php
PostgreSQL - The UPDATE Statement
PostgreSQL Operators PostgreSQL ... ANY PostgreSQL ALL PostgreSQL CASE ... The UPDATE statement is used to modify the value(s) in existing records in a table....
🌐
Reddit
reddit.com › r/postgresql › update fastest way
r/PostgreSQL on Reddit: Update fastest way
September 14, 2024 -

Hello,
We have to update a column value(from numbers like '123' to codes like 'abc' by looking into a reference table data) in a partitioned table with billions of rows in it, with each partition having 100's millions rows. As we tested for ~30million rows it's taking ~20minutes to update. So if we go by this calculation, it's going to take days for updating all the values. So my question is

  1. If there is any inbuilt way of running the update query in parallel (e.g. using parallel hints etc.) to make it run faster?

  2. should we run each individual partition in a separate session (e.g. five partitions will have the updates done at same time from 5 different sessions)? And will it have any locking effect or we can just start the sessions and let them run without impacting our live transactions?

UPDATE tab_part1
SET column1 = reftab.code
FROM reference_tab reftab
WHERE tab_part1.column1 = subquery.column1;

🌐
Neon
neon.com › postgresql › postgresql-tutorial › postgresql-update
PostgreSQL UPDATE Statement
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition RETURNING * | output_expression AS output_name; Let’s take some examples of using the PostgreSQL UPDATE statement.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › postgresql › postgresql_update_query.htm
PostgreSQL - UPDATE
In PostgreSQL, UPDATE statement is used to modify or change the existing records in a table. You can use WHERE clause with UPDATE statement to update the selected rows. Otherwise, all the rows would be updated.
🌐
DataCamp
datacamp.com › doc › postgresql › update
PostgreSQL UPDATE
In this syntax, `UPDATE table_name` specifies the table to modify, and `SET` assigns new values to the specified columns, optionally filtered by a `WHERE` condition.
🌐
SQLS*Plus
sqlsplus.com › postgresql-update-statement
PostgreSQL UPDATE statement - SQLS*Plus
The PostgreSQL UPDATE statement is used to update existing table entries in a database. The syntax for the UPDATE statement when updating a single table
Published   September 8, 2020
🌐
Reddit
reddit.com › r/postgresql › update column in a very large table (10m records)
r/PostgreSQL on Reddit: Update column in a very large table (10M records)
June 5, 2024 -

Hello, I'm trying to set a hash value on a column in a table which contains approx. 10 millions records. I tried many queries — no success. Btw, yes I've an index on cook_id in table.

Initially I tried this request :

WITH ranked_cook AS (
    SELECT 
        cook_id,
        DENSE_RANK() OVER (ORDER BY cook_id) AS hash
    FROM 
        table
    WHERE cook_id IS NOT NULL
)
UPDATE table
SET hash = ranked_cook.hash
FROM ranked_cook
WHERE table.cook_id = ranked_cook.cook_id;

Left my request all night — Woke up, it wasn't finish...so I cancelled it and told myself that it might be because of CTE which takes too long? Then I tried by creating a temp table, which took approx. 50min but finished then I tried to update from temp table but again left the query all night and wasn't finished when I woke up...

CREATE TEMP TABLE temp_ranked_cook AS
SELECT 
    cook_id,
    DENSE_RANK() OVER (ORDER BY cook_id) AS hash
FROM 
    table
WHERE 
    cook_id IS NOT NULL;

CREATE INDEX idx_temp_cook_id ON temp_ranked_cook(cook_id);

UPDATE table
SET hash = trc.hash
FROM temp_ranked_cook trc
WHERE table.cook_id = trc.cook_id;

Then I try to update by batches of 100 000 records, but still too long... Any idea?

🌐
EnterpriseDB
enterprisedb.com › postgres-tutorials › how-modify-data-postgresql-using-insert-update-update-joins-delete-and-upsert
How to modify data in PostgreSQL using INSERT, UPDATE, UPDATE JOINS, DELETE and UPSERT | EDB
postgres=# select * from tab1 ; pid | sales | status -----+-------+-------- 1 | 20 | CURR 2 | 40 | CURR 3 | 60 | ABS 4 | 30 | NEW (4 rows) postgres=# insert into tab1 (sales,status) values (30,'HOLD') ON CONFLICT (sales) DO NOTHING; INSERT 0 0 postgres=# select * from tab1 ; pid | sales | status -----+-------+-------- 1 | 20 | CURR 2 | 40 | CURR 3 | 60 | ABS 4 | 30 | NEW (4 rows) postgres=# insert into tab1 (sales,status) values (30,'HOLD') ON CONFLICT (sales) DO UPDATE SET status = 'PROD'; INSERT 0 1 postgres=# select * from tab1 ; pid | sales | status -----+-------+-------- 1 | 20 | CURR 2 | 40 | CURR 3 | 60 | ABS 4 | 30 | PROD (4 rows) ... How to use tables and column aliases... PostgreSQL vs. SQL Server (MSSQL)... The Complete Oracle to PostgreSQL Migration...
🌐
PostgreSQL
postgresql.org › docs › 9.1 › sql-update.html
PostgreSQL: Documentation: 9.1: UPDATE
October 27, 2016 - This documentation is for an unsupported version of PostgreSQL. You may want to view the same page for the current version, or one of the other supported versions listed above instead. ... [ WITH [ RECURSIVE ] with_query [, ...] ] UPDATE [ ONLY ] table [ * ] [ [ AS ] alias ] SET { column = { expression | DEFAULT } | ( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...] [ FROM from_list ] [ WHERE condition | WHERE CURRENT OF cursor_name ] [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
🌐
PostgreSQL Tutorial
pgtutorial.com › home › postgresql tutorial › postgresql update statement: updating data in a table
PostgreSQL UPDATE Statement: Updating Data in a Table
January 2, 2025 - We don’t use the WHERE clause in this example, so the statement updates all the rows. The output shows that the UPDATE statement updated four rows in the inventories table. The following SELECT statement retrieves all rows from the inventories table: SELECT name, price FROM inventories;Code language: PostgreSQL SQL dialect and PL/pgSQL (pgsql)
🌐
MSSQLTips
mssqltips.com › home › sql update statement with join in sql server vs oracle vs postgresql
SQL Update Statement with Join in SQL Server vs Oracle vs PostgreSQL
January 4, 2021 - As most DBA’s and developers that work with both SQL Server and Oracle already know, there are some differences in how you update rows using a join between SQL Server and Oracle. Notably, this is not possible with Oracle without some finesse. PostgreSQL has a similar ANSI SQL approach as SQL Server.
🌐
PostgreSQL
postgresql.org › docs › current › dml-update.html
PostgreSQL: Documentation: 18: 6.2. Updating Data
May 14, 2026 - Let's look at that command in detail. First is the key word UPDATE followed by the table name. As usual, the table name can be schema-qualified, otherwise it is looked up in the path.
🌐
TechOnTheNet
techonthenet.com › postgresql › update.php
PostgreSQL: UPDATE Statement
This PostgreSQL UPDATE example would update the first_name to the default value for the field in the contacts table where the contact_id is 35. If no default value has been set for the first_name column in the contacts table, the first_name column will be set to NULL. Let's look at a PostgreSQL UPDATE example where you might want to update more than one column with a single UPDATE statement.
🌐
Stormatics
stormatics.tech › home › ensuring safe data modifications in postgresql with select for update
Ensuring Safe Data Modifications in PostgreSQL with SELECT FOR UPDATE - Stormatics
December 30, 2025 - Without NOWAIT, the query would wait until the required locks become available, potentially causing delays or deadlocks. NOWAIT provides a way to handle concurrency more efficiently, allowing applications to handle lock conflicts in real-time rather than waiting indefinitely for resources to become available. postgres=# SELECT * FROM event_tickets WHERE seat_number = 'A1' AND status = 'available' FOR UPDATE nowait; ERROR: current transaction is aborted, commands ignored until end of transaction block
🌐
Tutorial Teacher
tutorialsteacher.com › postgresql › update-data
PostgreSQL Update Data in a Table
Use the UPDATE statement to modify existing data in the table. The UPDATE statement only updates data in the table and does not modify the structure of a table.