Could i add my slight tangent tip. Sql(delete,updates etc)
I got into habbit of writing my sql as
'zdelete from product where id = 123;' and THEN i remove the prefixed-z.
Too many a time i copy and pasted wrong ids or screwed up something else.
I got into habbit of writing my sql as
'zdelete from product where id = 123;' and THEN i remove the prefixed-z.
Too many a time i copy and pasted wrong ids or screwed up something else.
BEGIN;
DELETE FROM product WHERE id=123;
ROLLBACK;
--COMMIT;
And then I remove/comment the ROLLBACK and enable the COMMIT when I'm confident it's correct. This way I also get the number of affected rows for the statement.I do this even on the command line but it's handier in an Emacs buffer and for busy databases you then don't need to worry about other transactions and locking while you type.
SELECT Count(*) FROM product WHERE id = 123
And if the number looks right I replace "SELECT Count(*)" by "DELETE" begin;
delete from product where id = 123;
--verify things are correct with counts, by issuing "selects", etc.
and then issue either a "rollback;" or a "commit;"... I've been happy to have followed this pattern on occasion ;)