在 MySQL 中将字段从一个数据库复制到另一个数据库 [英] Copy fields from one database to another in MySQL
问题描述
我已经知道这里有和我一样的问题:
I have already known that here is question like mine:
PHP/MySQL:复制表和从一个数据库到另一个数据库的数据
但是,这个问题是大约 4 年前提出的,所以我今天想重复一遍.
But, that question was asked about 4 years ago, so I would like to repeat it today.
INSERT INTO `wp_estate`.`wp_posts`(post_title)
SELECT `s_description` FROM `u519633785_armar`.`oc_t_item_description`
WHERE `fk_i_item_id` > 4;
如何同时看到"两个数据库
How I can "see" two databases at the same time
推荐答案
你首先要创建一个表到你想要复制数据的数据库中.
You first have to create a table into database you want to copy the data.
获取表的完整CREATE
语句.在您的数据库中运行以下查询:
To get the complete CREATE
statement of table. Run Following query in your DB:
show create table table_name;
这将返回表的完整创建查询.
This will return you the complete create query of table.
在新数据库中创建表后,您可以将旧表中的所有数据复制到新数据库的表中.
After creating a table to your new database, you can copy all data from your old table to table of your new DB.
查询复制数据:
insert into newDB.your_table select * from oldDB.your_table;
更新插入查询:
INSERT INTO `wp_estate`.`wp_posts`(post_title)
SELECT `s_description` FROM `u519633785_armar`.`oc_t_item_description`
WHERE `fk_i_item_id` > 4;
这篇关于在 MySQL 中将字段从一个数据库复制到另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!