我们如何保存在sqlite3中创建的数据库 [英] how we can save database created in sqlite3

查看:261
本文介绍了我们如何保存在sqlite3中创建的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的数据库。我试图在其中创建一个数据库和表。
,但无法保存并在退出sqlite后再次打开。
我在centOS上使用sqlite3 3.6.20,当我将输入以下命令

I am new to database. I am trying to create a database and table in it. but unable to save and open again after exiting from sqlite. I am using sqlite3 3.6.20 on centOS, when i will enter following command

.save ex1.db or .open ex1.db

它将打印以下错误信息。

it will print following error message.

Error: unknown command or invalid arguments:  "save". Enter ".help" for help
Error: unknown command or invalid arguments:  "open". Enter ".help" for help

,当打印.help
时不显示任何命令相关保存和打开现有数据库。
。提前感谢。

and when Print .help it wont show any command related to save and open existing database. thanks in advance.

推荐答案


我试图创建一个数据库和表它。但无法保存并在退出sqlite后再次打开。

I am trying to create a database and table in it. but unable to save and open again after exiting from sqlite.

您不需要保存。每个事务写入磁盘。 (或多或少)。

You don't need to save. Each transaction writes to disk. (More or less.)

要创建数据库test.sl3,您可以这样做。 (从命令行。程序的工作方式大致相同。)

To create the database "test.sl3", you can do this. (From the command line. Programs work about the same way.)

$ sqlite3 test.sl3
SQLite version 3.8.7.2 2014-11-18 20:57:56
Enter ".help" for usage hints.
sqlite> create table test (test_id integer primary key);
sqlite> insert into test values (1);
sqlite> select * from test;
1
.quit

.save 。现在再次加载数据库。

No .save. Now load the database again.

$ sqlite3 test.sl3
SQLite version 3.8.7.2 2014-11-18 20:57:56
Enter ".help" for usage hints.
sqlite> select * from test;
1

数据仍然存在。

这篇关于我们如何保存在sqlite3中创建的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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