Merging two tables in PostgreSQL

I often have to merge data from different tables in PostgreSQL, this is a code snippet I use: MERGE INTO users u USING new_users n ON u.user_uuid = n.user_uuid WHEN NOT MATCHED THEN INSERT VALUES (n.user_uuid, n.first_name, n.last_name) WHEN MATCHED THEN UPDATE SET first_name = n.first_name, last_name = n.last_name RETURNING u.*;

12 February 2025 · 1 min

Running PostgreSQL with Podman and volume

This is a short snippet to run PostgreSQL using Podman with a volume. The snippet has been tested on Fedora 41. Create the Podman volume $ podman volume create psqldevel Run PostgreSQL $ podman run -d -p 5432:5432 -v psqldevel:/var/lib/postgresql/data -e POSTGRES_PASSWORD=xx --name psqldevel postgres:latest

10 February 2025 · 1 min