我正在使用Mac OS X, 我想创建一个新的SQLite DB,并且使用http://www.sqlite.org/quickstart.html作为参考。创建新的SQLite Db
我进入:sqlite3 test.db
并得到响应:
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
这究竟是为什么?
我正在使用Mac OS X, 我想创建一个新的SQLite DB,并且使用http://www.sqlite.org/quickstart.html作为参考。创建新的SQLite Db
我进入:sqlite3 test.db
并得到响应:
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
这究竟是为什么?
因为这是管理shell提示符。 shell创建了test.db,现在正在等待您对它做些什么,因此sqlite>
提示您看到。
此时您可能需要create table ...
。
所以很好。系统会提示您输入命令。创建表格,插入,选择。玩的开心!
您将被带到SQLite提示符(您可以在其中创建表格,添加数据等)。根据您发布的内容,没有任何东西显得与众不同。
它工作。退出并测试 - 数据库已创建。
你现在在SQLite的外壳,它已准备好接收像CREATE TABLE...
,INSERT INTO...
命令等
如果你不希望使用交互式shell,你可以在命令直接建立自己的模式行:
sqlite3 test.db "CREATE TABLE ..."
或者只是创建一个没有架构一个空数据库:
sqlite3 test.db ""
但是,这和上面一样无论如何创建一个空文件:
touch test.db
另外,使用'.exit'退出。非常有用的知道! – MPelletier 2010-04-13 13:34:29
其中test.db存储在哪里? – JustCurious 2012-02-04 04:47:50
@JustCurious,test.db存储在您发出命令的文件夹中。您也可以指定数据库文件的完整路径,例如,sqlite3 /tmp/test.db。 – 2012-03-01 01:27:36