Is there a way to insert data from a table in schema1 to a table in schema2 in mysql.
有没有办法将schema1中的表中的数据插入到mysql中的schema2中的表中。
Also , I assume there will be any access/privilege issues.
此外,我假设会有任何访问/权限问题。
My environment is Joomla using Fabrik extension, PHP, MySQL
我的环境是使用Fabrik扩展,PHP,MySQL的Joomla
Kindly share some tips
请分享一些提示
Thanks in advance
提前致谢
2 个解决方案
#1
1
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.
如果以root用户身份执行此操作,则不会出现权限问题。
- Backup your data first, though.
但是,首先备份您的数据。
#2
1
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
有关文档插入,请参阅以下内容..选择
#1
1
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.
如果以root用户身份执行此操作,则不会出现权限问题。
- Backup your data first, though.
但是,首先备份您的数据。
#2
1
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
有关文档插入,请参阅以下内容..选择