News for hackers. Stuff that matters.
Re:Unix recovery legend by IgorPartola on Tuesday March 23, 2010 @07:11AM (#1212660)
Command line mysql client has a i-am-a-dummy mode where you cannot run a query like "DELETE FROM table". You could of course run "DELETE FROM table WHERE 1=1" but at least it saves you sometimes.
Re:Unix recovery legend by Davertron on Tuesday March 23, 2010 @08:59AM (#1212778)
This is awesome, I never knew about this; I usually type "delete from where" and then fill out the query, just to avoid accidentally hitting enter after typing "delete from users".

For me, this is sort of like standing at the edge of a big cliff; you just have this weird feeling that you might accidentally, compulsively jump.

Re:Unix recovery legend by cynicalkane on Tuesday March 23, 2010 @10:20AM (#1212956)
Man, I thought I was the only one who felt like this (the cliff thing). I told a friend once and he became worried that I was suicidal. (I'm not.)
Re:Unix recovery legend by epochwolf on Tuesday March 23, 2010 @11:11AM (#1213076)
I get that too :)
Re:Unix recovery legend by daflip on Tuesday March 23, 2010 @10:00AM (#1212907)
WHERE 1=1 won't actually work when i-am-a-dummy mode is enabled. You must reference at least one KEY column in the where clause.
Re:Unix recovery legend by IgorPartola on Tuesday March 23, 2010 @11:00AM (#1213044)
Well, my point is that there are ways around it. Like WHERE id IS NOT NULL, or WHERE id=1 OR 1=1. It's not full-proof, it just protects you from writing out a query that is not complete.

It sort of sucks that in SQL you first say what action you want to perform and then say what you want to perform it on. I end up writing the WHERE part of every query first anyways.

Re:Unix recovery legend by k2jacob on Tuesday March 23, 2010 @07:28PM (#1214393)
In C# query syntax, you write in this order:

  from where select
I like it that way; it happens to already match the way my mind plans a relational query.
Re:Unix recovery legend by Pistos2 on Thursday March 25, 2010 @09:15PM (#1220004)
Also useful:

BEGIN;^M<potentially dangerous query>;^M<look at results>[COMMIT|ROLLBACK];^M