简体   繁体   中英

Copy from 1 table to another table

I am trying to copy from 1 table to another table on different database.

The SQL query dont seem to work:

INSERT INTO db1.table
  SELECT T.number, T.dob, T.house_number FROM `db2.table2` as T;

I am getting an error saying:

ERROR 1146 (42S02): Table 'db2.table2' doesn't exist

如果你坚持引用表名(不需要),它应该是

FROM `db2`.`table2`

你可以尝试这样的事情:

select * into dbo.test2 from dbo.test1
CREATE TABLE recipes_new LIKE production.recipes;
INSERT recipes_new SELECT * FROM production.recipes;

Check out this link: http://www.tech-recipes.com/rx/1487/copy-an-existing-mysql-table-to-a-new-table/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM