Secure connections
Save PostgreSQL connection details with encrypted passwords, SSL settings, URL import, testing, search, edit, and delete actions.
Edit PostgreSQL data
Editing rows is easy. Editing the rows you meant to edit, and only those, is the part worth learning. Everything on this page is about making the change visible before it is permanent.
Short answer: Run every data change inside an explicit transaction. Write the WHERE clause as a SELECT first, check the count, then convert it to an UPDATE, check the reported row count matches, and only then COMMIT. In a GUI client, use one that stages changes for review rather than writing each cell as you leave it.

PgDeck is shaped around PostgreSQL tasks that happen every day: connect, inspect, filter, edit, query, manage structure, copy, and export.
Save PostgreSQL connection details with encrypted passwords, SSL settings, URL import, testing, search, edit, and delete actions.
Browse schemas and tables, search the table list, pin favorites, filter rows, sort columns, resize columns, and paginate results.
Run SELECT and non-SELECT statements from multi-tab SQL editors with syntax highlighting and interactive query results.
Edit cells, add rows, duplicate rows, set NULL, stage deletes, review pending changes, and commit everything in one transaction.
Write the WHERE clause as a SELECT and look at what comes back. This one habit prevents most data incidents, because the mistake is almost never in the SET clause — it is in a WHERE that matches more rows than you expected, or none at all.
SELECT id, status FROM orders WHERE customer_id = 42 AND status = 'pending';BEGIN makes the change reversible until you commit. Without it, PostgreSQL autocommits each statement immediately and there is nothing to undo — recovery then means restoring a backup. This is the difference between a mistake and an incident.
BEGIN;PostgreSQL reports UPDATE 3 after the statement. If you expected three rows and it says three, continue. If it says 40000, you have just found the bug before it shipped. RETURNING goes further and shows you the actual rows that changed.
UPDATE orders
SET status = 'refunded', updated_at = now()
WHERE customer_id = 42 AND status = 'pending'
RETURNING id, status;COMMIT makes it permanent. ROLLBACK discards everything since BEGIN as though it never happened. If the row count surprised you, roll back — there is no cost to doing so and no penalty for being wrong.
COMMIT; -- or ROLLBACK; if the count was not what you expectedThese are different values and PostgreSQL treats them differently: NULL means unknown and fails any equality test, while '' is a known, empty value. Tools that silently turn a blank field into an empty string are a common source of quietly corrupted data.
UPDATE users SET middle_name = NULL WHERE id = 7;
-- Note: IS NULL, never = NULL, which is always unknown
SELECT count(*) FROM users WHERE middle_name IS NULL;A GUI grid that writes each cell as you leave it gives you the same risk as an unwrapped UPDATE. PgDeck holds every pending edit, insert, duplicate, NULL, and delete as one set, shows it for review, and commits it in a single transaction — the same discipline as the steps above, without typing them.
An UPDATE with no WHERE updates every row in the table, and PostgreSQL will run it without hesitation. There is no confirmation prompt and no undo outside a transaction. Writing the WHERE as a SELECT first is not being cautious, it is just how the statement should be built — you are checking the filter before attaching an action to it.
UPDATE ... FROM lets you set values based on a join, which is how you backfill a column or apply a correction supplied as a list. It is far safer than generating hundreds of individual UPDATE statements, because it is one atomic operation with one row count to check. Make sure the join cannot match multiple source rows per target row — PostgreSQL picks one arbitrarily rather than erroring.
An UPDATE that sets the wrong value can usually be corrected by another UPDATE if you know the old values. A DELETE outside a transaction is gone. Always run deletes inside BEGIN, always check the row count, and consider a soft delete column on tables where history has any value at all.
Holding a transaction open while you decide what to do blocks autovacuum from cleaning up and can block other writers on the rows you touched. Open the transaction, run the statement, check the count, and commit or roll back promptly. Do not BEGIN and then go to lunch — on a busy database that is its own kind of incident.
The whole point of the transaction pattern is that you see what will happen before it is permanent. A data grid that writes immediately removes that step, which is why editing production through one is risky. A client that stages the full pending set and commits it in one transaction gives you the review step and atomicity without typing BEGIN.
More on choosing, comparing, and running a PostgreSQL desktop client.
With UPDATE, ideally inside a transaction: BEGIN, run the UPDATE with a WHERE clause you have already tested as a SELECT, check the reported row count, then COMMIT or ROLLBACK. In a GUI client, edit cells in the data grid and commit the staged changes.
Only if you are inside a transaction that has not committed — then ROLLBACK discards it. Once committed there is no undo, and recovery means restoring from a backup or reconstructing the previous values. This is why BEGIN before a data change matters.
Add a RETURNING clause listing the columns you want back. UPDATE ... RETURNING id, status returns one row per row modified, so you see exactly what changed rather than only a count.
NULL means no value is known and fails every equality comparison, so you must test it with IS NULL. An empty string is a known value of zero length. Setting a field to '' when you meant NULL is a common and quiet form of data corruption.
Yes, in a GUI client's data grid. Prefer one that stages changes for review and commits them in a single transaction, rather than writing each cell as soon as you leave it — the review step is what makes editing production data reasonable.