#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Copy/Synch one table in two databases


    Hallo everyone,
    I have a noob question . Maybe someone can help me with this.

    Here is the scenario:
    I have two databases "db_1" and "db_2" on the same MYSQL Server for two LAMP websites ("site_1" and "site_2").

    They both have tables named "A" and "B".

    I need to make sure that the data from table "A" in "db_1" gets copied in regular intervals into table "A" in "db_2". It should be an exact copy of the table "A" in "db_1".

    "db_1" writes and reads it's table A but "db_2" only reads it's table "A".

    The tables called "B" have the same name in "db_1" and "db_2" but contain different data and are not compatible. So I cannot use one database.

    Sadly "site_1" and "site_2" are build on a CMS and I am not allowed to change any of their core PHP. That means I can't let them write/read from the same table "A".
    Any idea how I can safely synch this table over two databases?
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,141
    Rep Power
    9398
    But you can change the database stuff, right?

    Make the read-only table be a VIEW of the "master" table. No copying required.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by requinix
    But you can change the database stuff, right?

    Make the read-only table be a VIEW of the "master" table. No copying required.
    That could be exactly what I need.
    Thanks for the quick reply.

    Update: Worked perfectly.

IMN logo majestic logo threadwatch logo seochat tools logo