Postgres Daily
bobbyiliev's profile
Bobby Iliev@bobbyiliev•Aug 15, 2025
63.1K
Materialize's profile
Post cover image

PostgreSQL 18 Enhanced Returning Clause

From neon.com•Aug 15, 2025•8m read time

PostgreSQL 18 introduces enhanced RETURNING clause functionality that allows developers to access both old and new row values in a single DML operation. This eliminates the need for separate queries or complex triggers when tracking data changes. The feature introduces special 'old' and 'new' aliases that work across INSERT, UPDATE, DELETE, and MERGE operations, with customizable alias names to avoid conflicts. Key benefits include simplified audit trail implementation, better change tracking capabilities, and reduced code complexity. The enhancement is particularly valuable for INSERT...ON CONFLICT operations, UPDATE statements requiring before/after comparisons, and comprehensive DELETE logging.

Sort:

bobbyiliev's user avatar
Bobby Iliev
@bobbyiliev
Joined Sep 24. 2020
63.1K
Materialize's profile

Materialize

Verified

DevOps Engineer | Laravel enthusiast | Docker Captain

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard