Jump to content

Copying a Row From One Table to Another


Selacius

Recommended Posts

I am aware I can use the Insert Select query, but I am curious how to do that when the two tables are in separate databases?

If you are talking about two databases in the same DMBS environment, then its possible.Like if you have two databases in two different oracle environments, I mean both the database are oracle database; and you want to access the tables of the other database then its possible through dblink. Suppose..Table1 is in database1Table2 is in database2 Log in to database1 and issue query
select * from table1; //this would work because the table is in same database.

Now create dblink (in database1) for database2 as dblink_db2issue query

select * from table2@dblink_db2

This would fetch the records from table2 of database2 ( despite the fact that you are logged in database1).

Link to comment
Share on other sites

Actually, I solved my problem. I ran a query in phpmyadmin which copied a table from one database to another. Then I modified the resulting query to match the columns that were required for both the SELECT and INSERT. My main problem was I wasn't sure how to define the two different databases in the INSERT SELECT mysql query.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...