Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2005
    Location
    Eastern US
    Posts
    488
    Plugin Contributions
    0

    Default Needing sql query to drop table prefix

    I have a database that was set up with table prefixes. I need to export the data from some of the tables then import it into another zen database that does not have any prefix.

    I am looking for an sql query to drop the table prefix, so that when I export/import the data will fall into the correct tables rather than creating new ones.

    Any help appreciated!
    Audra

  2. #2
    Join Date
    Mar 2004
    Posts
    16,042
    Plugin Contributions
    5

    Default Re: Needing sql query to drop table prefix

    once you have it downloaded open it in a text editor and do a search replace for the prefix_ and replace it with a blank


    ALERT!!!!! See DrByte's note below for caveats to this approach!!




    .
    Zen cart PCI compliant Hosting

  3. #3
    Join Date
    Oct 2005
    Location
    Eastern US
    Posts
    488
    Plugin Contributions
    0

    Default Re: Needing sql query to drop table prefix

    That was simple, thank you.

  4. #4
    Join Date
    Mar 2004
    Posts
    16,042
    Plugin Contributions
    5

    Default Re: Needing sql query to drop table prefix

    quite welcome,
    if you were going to be moving the configure tables that wouldnt work that easy but since only moving customers and orders products will work fine
    Zen cart PCI compliant Hosting

  5. #5
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Needing sql query to drop table prefix

    as an addendum for others reading this thread, be very careful about doing a carte-blanche replacement of "prefix_" especially if it's "zen_".

    You're better off searching for "CREATE TABLE prefix_" and then removing the "prefix_" portion. This can be automated quite easily with most text editors. You should do similarly with DROP TABLE and INSERT INTO statements.


    Another thing to note: If you simply want to rename all the tables in your database to remove or change the prefix ... on the live site ... simply use the "change prefix" fields in the Database Upgrade screen of the zc_install tools.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Aug 2009
    Location
    UK
    Posts
    71
    Plugin Contributions
    0

    Default Re: Needing sql query to drop table prefix

    I needed to import a datbase with a zen_ prefix into a new store without a zen_ prefix as part of a 139 upgrade and this method of editing the database export file seemed to work well.

    I noticed that most of the other posts suggest using the zc_install database upgrade method. DOes anyone know whether this file editing method is sound?

 

 

Similar Threads

  1. Replies: 9
    Last Post: 12 Jul 2023, 12:26 AM
  2. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  3. v139h Save the Multi Table Query Result in phpmyadmin or by SQL CLI
    By explorer1979 in forum General Questions
    Replies: 2
    Last Post: 31 Dec 2013, 09:03 PM
  4. v151 SQL query setup. How do I TEST a query 'off-line'?
    By lewisasding in forum General Questions
    Replies: 3
    Last Post: 8 Mar 2013, 12:24 AM
  5. Replies: 2
    Last Post: 15 Aug 2011, 04:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg