4 ms·
In terms of actually writing queries live, like if you're in the CLI client, the order of UPDATE is definitely terrifying. The workarounds of writing it out of
by zerocrates 3y ago
In terms of actually writing queries live, like if you're in the CLI client, the order of UPDATE is definitely terrifying.
The workarounds of writing it out of order or as a SELECT first are fine... I'd almost like to see a mode the interactive client sets that just rejects any UPDATE without a WHERE, and you'd have to do WHERE 1 or similar to get an "UPDATE everything."
- mulmen 3y agoIf you are doing an update the first word is actually BEGIN. /* use your PPE */ BEGIN; /* make the change */ UPDATE foo SET bar = ‘baz’; /* sanity check */ SELECT * FROM foo WHERE bar != ‘baz’; /* oops, let’s pretend this never happened */ ROLLBACK;
- dotancohen 3y agoThat might help in dev, but nobody would use transactions when hand manipulating the live production database. ))