无法打开数据库“test.sql”:无法在xcode中打开数据库文件

时间:2012-08-10 08:06:50

标签: objective-c xcode4

我是客观的新手。我正在尝试在我的mac中第一次创建数据库,我按照步骤

进行了操作
******100$ sqlite3 test.sql
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

但是我输入.schema我收到了以下错误

sqlite> .schema
Error: unable to open database "test.sql": unable to open database file

如果我去创建一个teble

,同样的错误

3 个答案:

答案 0 :(得分:0)

您可以使用Firefox插件SQLite Manager来创建数据库。

答案 1 :(得分:0)

尝试这样的事情:

$ sqlite3 test.sql
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test (a_int INTEGER, a_real REAL, a_text TEXT);
sqlite> .schema
CREATE TABLE test (a_int INTEGER, a_real REAL, a_text TEXT);
sqlite> INSERT INTO test (a_int, a_real, a_text) VALUES (1, 1.24, 'hello world');
sqlite> SELECT * from test;
1|1.24|hello world
sqlite> 

(这是来自Linux,但它应该是相同的......)

BTW文件扩展名.sql错误;用于包含SQL语句的文件。请改用.db

答案 2 :(得分:0)

选中此链接以创建数据库,创建表插入表。

Creating an SQLite3 database file through Objective-C

相关问题