简体   繁体   English

将一列从一个表复制到mysql中的另一个表(两个不同的数据库)

[英]Copy a column from one table to another in mysql (two different databases)

I tried to copy a column from one table to another table (in two different databases) 我试图将一列从一个表复制到另一个表(在两个不同的数据库中)

I tried the following queries: 我尝试了以下查询:

update des_db.mytable as des 
set col=  (select col from src_db.mytable as src where src.id = db.id)

and also joining these two tables. 并连接这两个表。
In both solutions, I got the error "Total number of locks exceed the lock table size". 在这两种解决方案中,我都收到错误“锁总数超过了锁表大小”。
I increased the "innodb_log_buffer_size to 32M and it doesn't work. 我将“ innodb_log_buffer_size增加到32M,它不起作用。

I want to know if there is any solution to do this. 我想知道是否有解决方案。

IMPORTANT NOTE: the source table is actually my backup and it has the same number of rows as the other one has. 重要说明:源表实际上是我的备份,它的行数与另一个表相同。 (666,666 records) (666,666条记录)

This way it should work: 这样,它应该可以工作:

UPDATE
des_db.mytable 
INNER JOIN src_db.mytable ON des_db.mytable.id = src_db.mytable.id
SET
des_db.mytable.col = src_db.mytable.col;

Unfortunately I can't test it right now, but I'm quite sure this works. 不幸的是,我现在无法对其进行测试,但是我很确定这是可行的。 Aliases should work also. 别名也应该起作用。

UPDATE database1.table1, database2.table1
SET database1.table1.columnA = database2.table1.columnA
WHERE database1.table1.id = database2.table1.id;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将一列复制到另一张表中的mysql - Copy one column to another in different table mysql MySQL将两个表列复制到具有不同列名的另一个表 - MySQL copy two table columns to another table with different column names 将一个表插入另一个表(来自不同的数据库) – MySQL - Insert one table into another (from different databases) – MySQL 使用MySQL将数据从一列复制到另一张表中的另一列 - Copy Data from one column to another column in a different table using MySQL 如何从一个mysql表复制到具有不同列类型定义的另一张表? - How can I copy from one mysql table to another table with different column type definitions? MySQL两个数据库,一种情况下按一列排序,不同情况下按另一列排序 - MySQL Two databases, order by one column in one case, order by another column in different case MySql中如何将列数据从一张表复制到另一张表? - How to Copy Column data from one table to another table in MySql? 从一列复制到另一列(不同的表相同的数据库)mysql - Copy from one column to another (different tables same database) mysql 从不同的MySQL数据库表和不同的列名复制数据 - Copy data from different MySQL databases tables and different column names 通过比较来自不同数据库的两个不同列,使用 PHP MySql 从表中检索列 - Retrieve a column from a table by comparing two different columns from different databases, using PHP MySql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM