Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mysql - Copying Info to another database??

Posted on 2006-06-20
3
Medium Priority
?
249 Views
Last Modified: 2008-03-10
Hi

I have got a scheduled task in place that moves information from 1 database (Firebird) to another (MySQL). The issue that i have, is that some information that goes into the MySQL database, also needs to be in ANOTEHR MySQL database, which is stored on the same server.

Rather than modifying the scheduled task to do 2 updates, is it possible to create a trigger, that would move selected data into the other database.

E.g. If account = "041" then copy field A, B, C, D into the other database

Is this possible?

Thanks very much

PS - high point score as it would be very valuable to me
0
Comment
Question by:seancurt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16943913
Yes, it is absolutely possible, as long as the server is MySQL 5.0 and the databases are hosted by the same MySQL server instance.
0
 

Author Comment

by:seancurt
ID: 16948985
Hi

That sounds great, but how?
0
 
LVL 30

Accepted Solution

by:
todd_farmer earned 2000 total points
ID: 16952666
The script below gives you an idea on how to start.  You will need another trigger for capturing UPDATE events and another for DELETE events, if appropriate:

create database db1;
create database db2;
use db1;
create table test (id int unsigned not null auto_increment primary key, name varchar(15), created timestamp);
use db2;
create table test_target(id int unsigned not null primary key, name varchar(15), friend varchar(15));
use db1;
delimiter ||
create trigger test_ins after insert on test
for each row begin
insert into db2.test_target (id, name) values (new.id, new.name);
end;
||
delimiter ;
insert into test (name) values ('Todd');
select * from db2.test_target;

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question