我正在学习 sqlite3
的初学者教程。第一步是创建一个新数据库。所以我输入了一个名称 (movies.db
)。
我希望在下一行得到另一个 sqlite>
提示,然后继续本教程,但我得到一个蹩脚的 ...>
之后我可以输入任何我想要的乱码。显然,这不好。
我的命令提示符是这样的:
SQLite version 3.8.1 2013-10-17 12:57:35
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> $ sqlite3 movies.db
...> gibberish
...> dsds
...> sdada
...> gfgys
...> a
...> Aaaaarrrgh!
...>
如何让 sqlite3 为我正常工作?
请原谅我的新手。我希望我用一种可能对其他新手也有帮助的方式来表达这个问题。
最佳答案
Sqlite 正常工作。但是,sqlite movies.db
命令应该从您的系统 命令行发出——而不是从 Sqlite 交互式 shell。首先退出 Sqlite 交互式 shell (.exit
),然后发出数据库创建命令。
At a shell or DOS prompt, enter: "sqlite3 test.db". This will create a new database named "test.db". (You can use a different name if you like.)
Enter SQL commands at the prompt to create and populate the new database.
从系统命令行正确执行 sqlite movies.db
命令后,您将自动进入 Sqlite 交互式 shell,等待命令。
sqlite> create table tbl1(one varchar(10), two smallint);
...>
shell 提示符表示上一行的延续。如消息中所示,您需要使用 ;
分号终止每个数据库命令。
sqlite> CREATE TABLE tbl2 (
...> f1 varchar(30) primary key,
...> f2 text,
...> f3 real
...> );
sqlite>
关于SQLite3 提示 `...>` 而不是 `sqlite>`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19710968/