I have a complicated situation where I would like to prevent inserts into a MySQL table, but keep it open for edits/updates to existing data. Can this be done? I've searched around here, but could not find a similar situation.
Use a before insert trigger to set the new values back to the old ones? Or, even better, set it to do nothing at all - as per below. As Eric Raymond pointed out in his (good) book "The Art of Unix Programming", the fastest code is that which doesn't have to run at all!. (Note - don't have a running system to test - but I think the underlying concept is pretty clear!).
DELIMITER $ CREATE TRIGGER blank_insert BEFORE INSERT ON test1 FOR EACH ROW BEGIN ; END; $ DELIMITER ;
Perhaps an even more elegant way would be to do what's outlined here - i.e. set PRIVILEGES to UPDATE and SELECT only for your users on your table?