简体   繁体   English

在连接的数据库中创建表并从另一个连接检索数据

[英]Creating a table in a database of a connection and retrieving data from another connection

So I came up with a situation where I need to create a table on a database (Connection 1) and need to fill it up with data from another connection (Connection 2).所以我想出了一种情况,我需要在数据库(连接 1)上创建一个表,并需要用来自另一个连接(连接 2)的数据填充它。

Right now I am creating these tables and filling them up with a select query in the same server using this example: CREATE TABLE table 1 as SELECT * FROM database.dataTable , However I am stuck to Create table1 in a database in (Connection 1) and filling it up from (Connection 2).现在我正在创建这些表并使用此示例在同一服务器中使用选择查询填充它们: CREATE TABLE table 1 as SELECT * FROM database.dataTable ,但是我坚持在(连接 1)中的数据库中创建table1并从(连接 2)填充它。

To explain my self better I need to do something like this CREAT TABLE table1(Connection 1) as SELECT * FROM database.dataTable(Connection 2) .为了更好地解释我自己,我需要做这样的事情CREAT TABLE table1(Connection 1) as SELECT * FROM database.dataTable(Connection 2) I am using python.我正在使用蟒蛇。

Create table as select is done as a single operation.创建表作为选择是作为单个操作完成的。 You can't do that with 2 connections.你不能用 2 个连接来做到这一点。 If you still need to do it by using 2 connections, you will have to create the table in one then, once the table exists, fill it with the second one.如果您仍然需要使用 2 个连接来完成此操作,则必须在一个连接中创建该表,然后,一旦该表存在,就用第二个连接来填充它。 It doesn't look optimal.它看起来不是最佳的。

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

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