如何创建一个内存数据库架构基于现有文件数据库 [英] How to create an in-memory database with schema based on an existing file database

查看:217
本文介绍了如何创建一个内存数据库架构基于现有文件数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的数据库,结构用于​​翻过整个应用程序。数据库的实例定期轮换。我有被用作所有新创建的数据库模板的数据库文件 template.sqlite 。我想用它,而不是创建脚本,所以我要保持只有一个文件,空数据库模板本身。

I have an existing database which structure is used accross the whole application. Instances of the databases are periodically rotated. I have a database file template.sqlite which is used as a template for all newly created databases. I want to use it, not a creation script, so that I have to maintain only one file, the empty database template itself.

我想创建一个内存数据库具有相同的结构基于该模板文件。

I would like to create an in-memory database with the same structure based on that template file.

我知道我能打开数据库,读它的结构,然后在内存中手动创建数据库。如果可能的话,我希望能够做到这一点更自动的方式。

I know I can open the database and read it's structure, then create the database manually in memory. If possible, I would like to be able to do it in a more automatic way.

推荐答案

您可以使用的使用.dump 命令:// WWW。 sqlite.org/sqlite.html相对=nofollow>命令行shell 确实创造了一堆SQL命令,就可以执行。

You could use the .dump command of the command-line shell do create a bunch of SQL commands that you can execute.

另外,您也可以使用备份API 的模板复制到一个新的数据库。

Alternatively, you can use the backup API to copy the template into a new database.

这篇关于如何创建一个内存数据库架构基于现有文件数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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