On Wed, 21 Jun 2006 11:12:40 -0400, Kevin Old wrote: > Hello everyone, > > I had a horrible thing happen to me this morning and wanted to make it > known to the community. > > I needed to delete a record from a very large table (yes, it was > backed up) and like the cli interface of mysql. I ran this query: > > delete from tablename where id - 12345; > > Notice that I accidentally hit the dash (-) instead of the equal (=). > It proved to be disasterous as it deleted all the records from that > table. > > Lucky for me I had a backup from last night and not too many records > were added since then and I was able to restore. > > For the record, I am aware of the "select before delete" method, but > didn't use it in this one instance and it meant a few hours restoring > data. > > Just wanted to throw this out and see if others had possible solutions > for working with the mysql cli interface for maybe setting up "rules" > for it to cancel a query if it contains a certain character (like the > dash). Fat chance there is, but I thought I'd ask. > > Hope this helps someone, > Kevin > -- > Kevin Old > [EMAIL PROTECTED]
Doesn't mysql have transactions? If it does you could just start a transaction before you do anything. This is what I do with PostgreSQL. As I recal oracle's sqlplus does this by default. begin; -- or something -- do some stuff -- if you did something dumb rollback; -- or something -- otherwise commit; -- or something -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]