Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    16
    Member #
    14937
    Hi All

    Can I ask how best to update one MySQL database from another. Both databases use the same tables as they are from the same shopping cart though the content is somewhat different.

    DROP TABLE IF EXISTS cscart_access_restriction_emailcc;
    CREATE TABLE `cscart_access_restriction_emailcc` (
    `item_id` int(11) unsigned NOT NULL auto_increment,
    `value` varchar(66) NOT NULL default '',
    `type` char(3) NOT NULL default '',
    `avail` char(1) NOT NULL default 'Y',
    `timestamp` int(11) NOT NULL default '0',
    PRIMARY KEY (`item_id`),
    KEY `type` (`type`)
    ) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;

    To merge the two would i use the statement UPDATE tables instead of DROP TABLE IF EXISTS something like this

    UPDATE tables cscart_access_restriction_emailcc;
    CREATE TABLE `cscart_access_restriction_emailcc` (
    `item_id` int(11) unsigned NOT NULL auto_increment,
    `value` varchar(66) NOT NULL default '',
    `type` char(3) NOT NULL default '',
    `avail` char(1) NOT NULL default 'Y',
    `timestamp` int(11) NOT NULL default '0',
    PRIMARY KEY (`item_id`),
    KEY `type` (`type`)
    ) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;

    Thanks in advance
    www.demontemplates.com
    Cubecart Templates | Cubecart Skins | Cubecart Designs

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Your question is a little ambiguous. Not sure what you're asking.

    You can't UPDATE the structure of a table, but you can ALTER it.

    You can update from one database catalog to another if they're on the same server, like so:

    INSERT INTO db2.cscart_access_restriction_emailcc SELECT * FROM db1.cscart_access_restriction_emailcc

  4. #3
    Junior Member
    Join Date
    Mar 2007
    Posts
    16
    Member #
    14937
    Quote Originally Posted by smoseley
    Your question is a little ambiguous. Not sure what you're asking.

    You can't UPDATE the structure of a table, but you can ALTER it.

    You can update from one database catalog to another if they're on the same server, like so:

    INSERT INTO db2.cscart_access_restriction_emailcc SELECT * FROM db1.cscart_access_restriction_emailcc
    So what you are saying is I can add the statement as follows;

    INSERT INTO db2.cscart_access_restriction_emailcc SELECT * FROM db1.cscart_access_restriction_emailcc;
    CREATE TABLE `cscart_access_restriction_emailcc` (
    `item_id` int(11) unsigned NOT NULL auto_increment,
    `value` varchar(66) NOT NULL default '',
    `type` char(3) NOT NULL default '',
    `avail` char(1) NOT NULL default 'Y',
    `timestamp` int(11) NOT NULL default '0',
    PRIMARY KEY (`item_id`),
    KEY `type` (`type`)
    ) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;
    www.demontemplates.com
    Cubecart Templates | Cubecart Skins | Cubecart Designs

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    no, other way around. first you create the table, then you populate it with the data from the other database.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:57 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com