sqlite 从具有完全相同架构的两个数据库中附加两个表 [英] sqlite append two tables from two databases that have the exact same schema

查看:27
本文介绍了sqlite 从具有完全相同架构的两个数据库中附加两个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将数据写入 sqlite 数据库,但由于数据集非常大,我将整个过程分为五个部分.结果,我同时写入五个不同的sqlite数据库,每个数据库都有相同的列名,最后,我想将五个数据库中的五个表一起附加到一个表中.有什么方法可以做到这一点?

I'm writing data into an sqlite database, but because the data set is very large, I'm splitting the process into five pieces. As a result, I'm writing to five different sqlite databases at the same time, each having the same column names, and in the end, I want to append the five tables in the five databases together into one table. What is the way to do this?

推荐答案

您可以使用 ATTACH使另一个数据库文件的内容可在同一连接中访问:

You can use ATTACH to make the contents of another database file accessible in the same connection:

ATTACH "/some/where/db2.sqlite" AS db2;
INSERT INTO main.MyTable SELECT * FROM db2.MyTable;

(主数据库总是被称为main;打开一个新的数据库连接相当于ATTACH "filename" AS main.)

(The main database is always called main; opening a new database connection is the equivalent of ATTACH "filename" AS main.)

这篇关于sqlite 从具有完全相同架构的两个数据库中附加两个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆