如何在MySQL cli中插入另一个数据库表

时间:2014-05-21 19:47:40

标签: mysql sql

[dev@server public_html]$ mysql dev_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 860167
Server version: 5.6.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> INSERT INTO `production_db.gg_weekly_report` (`submitted_by`, `report`) VALUES ('1541', 'test');
ERROR 1146 (42S02): Table 'dev_db.production_db.gg_weekly_report' doesn't exist
mysql> 

有没有这样做?是的,用户可以访问这两个数据库。

1 个答案:

答案 0 :(得分:2)

数据库名称和表名称是单独的标识符,因此您需要单独分隔它们:

mysql> INSERT INTO `production_db`.`gg_weekly_report` ...