1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Find and replace SQL

Discussion in 'General PHP and MySQL Discussions' started by Slavik, Oct 11, 2011.

  1. Slavik

    Slavik XenForo Moderator Staff Member

    I have had a client transfer a Magento to me recently from their old host which was shutting down.

    Unfortunately, the old host was unaware of Magento's.... features, and sent me a database that was screwed up big time. I have managed to fix the majority of the damage via a lot of effort. But the final hurdle is replacing a lot of missing quotation marks.

    They have all been changed from ' to ’

    The problem is, I don't want to have to run a query on 220 individual tables...

    So any suggestions on how to run it and search ALL tables for ’ and if found, replace it with '

    Im guessing some sort of regular expression... however I will happilly admit, RegEx is something I can't get my head around... I know what it does and how it does it... but not how to form it into something I would use.

  2. Brogan

    Brogan XenForo Moderator Staff Member

    How big is the database?

    Can you export it, open it in an editor and do a find and replace there, then import it again?
  3. Slavik

    Slavik XenForo Moderator Staff Member

    The thought had passed my mind, unfortunately it is several GB, so not realy an option :(
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Can't you run the query on the largest few tables, then export the remainder and do it via an editor?

    I don't know Magento but I'm guessing only a handful of tables will make up the majority of the size.
  5. Slavik

    Slavik XenForo Moderator Staff Member

    You might be onto something :) Cheer sBrogan!
  6. Slavik

    Slavik XenForo Moderator Staff Member

    Unforutnately no dice :(
  7. EasyTarget

    EasyTarget Well-Known Member

    Have you looked at this program

    If you can export it into a flat file there are plenty of perl scripts out there that can blow throw the file and do a find / replace. I've run scripts like this on >50GB flat files and usually only takes 5-10 minutes to process. YMMV.

Share This Page