合并两个 SQLITE 数据库的最快方法 [英] Fastest Way merge two SQLITE Databases

查看:42
本文介绍了合并两个 SQLITE 数据库的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 3 个 SQLite 数据库,每个数据库在表结构方面具有完全相同的 7 个表集.[它们是来自 3 台不同机器的日志转储].

I have 3 SQLite DBs, each having exactly the same set of 7 tables with respect to table structure. [They are Log Dumps from 3 different Machines].

我想将它们组合成一个 SQLite DB,具有相同的 7 个表,但每个表都应包含来自所有三个 DB 的组合数据.因为我想对其中 3 个运行查询.什么是最好,最快的方法.

I want to combine them into one SQLite DB, having those very same 7 tables, but each table should have the combined data from all the three DBs. since I want to run queries across the 3 of them. What is the best, fastest way to do it.

推荐答案

将每个数据库导出到 SQL 转储,然后将转储导入到新的组合数据库中.

Export each database to an SQL dump and then import the dumps into your new combined database.

对于 GUI,请查看 http://www.sqlite.org/cvstrac/wiki?p=管理工具

For GUIs have a look at http://www.sqlite.org/cvstrac/wiki?p=ManagementTools

例如,使用 SQLiteStudio 将成为数据库>导出数据库:导出格式:SQL >完成.

For example, with SQLiteStudio that will be Database > Export the database: Export format: SQL > Done.

使用命令行 sqlite 实用程序(在 linux repos 中可用并且通常已经存在 ootb),您可以通过以下步骤创建转储:

With the command line sqlite utility (available in linux repos and often already present ootb) you can create a dump with these steps:

# starts the interactive prompt
sqlite3 my_database.sqlite

sqlite> .output my_dump.sql
sqlite> .exit

从交互式提示导入转储文件:

To import a dump file from the interactive prompt:

sqlite> .read export.sqlite3.sql

您也可以直接从 shell 导入:

You can also import directly from shell:

cat my_dump.sql | sqlite3 my_database.sqlite

这篇关于合并两个 SQLITE 数据库的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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