我是sqlite的新手。我正在制作一个安卓应用程序。在服务器端,我想要一个sqlite中的数据库。但无法在其上创建自己的数据库。
sqlite> mydb.db;
或
sqlite> sqlite3 mydb.db;
或
sqlite> $sqlite3 mydb.db;
Error: near "mydb": syntax error
sqlite> $ sqlite3 mydb.db;
Error: unrecognized token: "$"
我已经尝试了以上所有的命令,但它给出了错误。请告诉我什么是正确的命令。提前谢谢。
所有这些都是像谷歌搜索一样从第一个开始复制粘贴。现在找出差异,它就会起作用:)
For example, to create a new SQLite database named "ex1" with a single table named "tbl1", you might do this:
$ sqlite3 ex1
SQLite version 3.8.4 2014-02-11 16:24:34
Enter ".help" for usage hints.
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>
sqlite> CREATE TABLE tbl2 (
...> f1 varchar(30) primary key,
...> f2 text,
...> f3 real
...> );
您应该从bash或任何其他shell而不是从sqlite控制台运行此sqlite3 mydb.db
命令。您可以使用.databases
命令在sqlite控制台中检查结果:
这是我的输出:
laptop@~$ sqlite3 mydb.db
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main /home/nyitrai/mydb.db
sqlite>