Hacker News new | past | comments | ask | show | jobs | submit login

I will typically do something like this when writing SQL in an interactive tool:

  SELECT * from table
  WHERE id = 12345
and once that's giving me the selection I want, insert the update statement into the middle:

  SELECT * from table
  -- UPDATE table set c1 = v1, c2 = v2
  WHERE id = 12345
Then, accidentally running the entire buffer doesn't do anything destructive, but selecting the query from update to the end of the statement lets me do the update. (It's still imperfect, because selecting only the update line will still be destructive.)

(Most of the RDBMS tools that I've used would happily ignore the lack of a closing semi-colon and that will not save you for a single-statement case.)




True, thought I didn't include the lookup first, it is how it happens in practice. Also, we use the mysql client, so semicolon is a must, and I would avoid anything that let you submit the statement without it...that's your safety net.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: