kelly
kelly

Reputation: 193

mysql inserting data from one schema to another

Is there a way to insert data from a table in schema1 to a table in schema2 in mysql.

Also , I assume there will be any access/privilege issues.

My environment is Joomla using Fabrik extension, PHP, MySQL

Kindly share some tips

Thanks in advance

Upvotes: 2

Views: 4008

Answers (2)

Stephane Gosselin
Stephane Gosselin

Reputation: 9148

This query does that:

INSERT INTO db2.table1 SELECT * FROM db1.table1;
  • Not tested but should do the job.

If you do this as root user, you will have no permission issues.

  • Backup your data first, though.

Upvotes: 1

Wes
Wes

Reputation: 6585

You can always preface the table name with the database name and as long as the user has the appropriate permission you can do:

insert into db1.users( first, middle, last )
select a.first, a.middle, a.last from db2.users a

See the following for the documentation insert .. select

Upvotes: 1

Related Questions