Copy-Down in SQL
April 14, 2009 10:36 PM
Subscribe
Is there a GUI SQL editor that emulates a spreadsheet-style "copy down"? If not, is there a technique I should learn?
I seem to spend 10-15 mins a day touching up some mysql data in a huge remote CRM-type database (I don't have shell access) and I notice that I spend most of that time copy-pasting the same corrections down one column for 50 or 60 rows. (I do a select to find new stuff, eyeball it, and find that one of the records has the right info and the other fifty need to be made the same, or none are right and I need to change them all).
If I was using a spreadsheet like Excel, that would take 2 seconds (drag down a range, control-d duplicate), but I haven't found a GUI SQL editor that can do this, so I click-copy-paste-click for 15 mins. This is time-wastey and feels silly. There's got to be an easier way.
(I realize that technically the app would have to do 60 individual updates, but that would be behind the scenes while I move on to more fun parts of my day, right?)
So is there a GUI SQL app that emulates the "copy down" of spreadsheets? Or if I were more clueful, is there a stored statement or "macro" I could make in one of these things that would take the selected field in the current record and dupe it down down down? If so, kick me in the right direction: I'm no database geek but I'm not wholly useless technically, either. I can probably learn from a few examples. (15 mins a day times 200 days a year is enough time to be worth reading a book!)
I'd prefer OSX but I would use Windows or Linux for a few minutes per day if the right tool is out there. For OSX, I've tried out the official mysql client, RazorSQL, Navicat, SequelPro, and SQLgrinder. Some are better than others at the copy-paste and ad hoc correcting I do, but none have "duplicate down".
These seems simple enough (to my pretty little head) that I must be missing something.
posted by rokusan to technology (10 comments total)
3 users marked this as a favorite
I'd select the table's id column for all rows I wanted to change, and paste that to the end of
"update tablename set column = value where id in" (paste) ";"
to get "update tablename set column = value where id in (1, 4, 7, 1729) ;"
And then execute that single statement.
Advantages: no copying down, one update statement that updates one column's values instead of sixty updates that may be updating the values in all columns.
posted by orthogonality at 10:47 PM on April 14