如何创建新的 SQLite 数据库?
我正在 Mac OS X 上工作, 我想创建一个新的 SQLite 数据库,并且 我使用 http://www.sqlite.org/quickstart.html 作为参考。
我正在输入:sqlite3 test.db
并得到答复:
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
为什么会发生这种情况?
I am working on Mac OS X,
I want to create a new SQLite DB, and
I am using http://www.sqlite.org/quickstart.html as a reference.
I am entering: sqlite3 test.db
and getting the response:
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
Why is this happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它起作用了。退出并测试 - 数据库已创建。
您现在处于 SQLite shell 中,并且已准备好接收诸如
CREATE TABLE...
、INSERT INTO...
等命令。如果您不想这样做使用交互式 shell,您可以直接从命令行构建模式:
或者只是创建一个没有模式的空数据库:
但这与创建一个空文件相同:
It worked. Quit out and test - the database has been created.
You are now in the SQLite shell, and it is ready to receive commands like
CREATE TABLE...
,INSERT INTO...
, etc.If you would prefer not to use the interactive shell, you can build your schema straight from the command line:
Or just create an empty database with no schema:
But that's the same as just creating an empty file, anyway:
因为那是管理 shell 提示符。 shell 创建了 test.db,现在正在等待您对其执行某些操作,因此您会看到
sqlite>
提示符。此时您可能想要
创建表...
。Because that is the administrative shell prompt. The shell created test.db and is now waiting for you to do something with it thus the
sqlite>
prompt you see.You may want to
create table ...
at this point.所以没关系。系统会提示您输入命令。创建表,插入,选择。玩得开心!
so it is fine. you are prompted to enter commands. create table, insert, select. have fun!
您将进入 SQLite 提示符(您可以在其中创建表、添加数据等)。根据您发布的内容,没有任何异常。
You're being taken to the SQLite prompt (where you can create tables, add data, etc.). Nothing appears out of the ordinary based on what you've posted.
例如,使用新数据库名称
mydb.sqlite3
运行 SQLite3 并创建如下所示的表person
可以创建新数据库mydb.sqlite3
:并且,您可以通过一行命令来完成上述操作,如下所示:
或者:
请注意,仅使用如下所示的新数据库名称
mydb.sqlite3
运行 SQLite3 无法创建新数据库mydb.sqlite3
:此外,您可以使用
''
或""
创建空数据库mydb.sqlite3
,如图所示如下:或:
For example, running SQLite3 with the new database name
mydb.sqlite3
and creating the tableperson
as shown below can create the new databasemydb.sqlite3
:And, you can do the above with one line of command as shown below:
Or:
Be careful, only running SQLite3 with the new database name
mydb.sqlite3
as shown below cannot create the new databasemydb.sqlite3
:In addition, you can create the empty database
mydb.sqlite3
with''
or""
as shown below:Or: