?
Solved

Mysql - Copying Info to another database??

Posted on 2006-06-20
3
Medium Priority
?
248 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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

777 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