2012-08-10 156 views
1

我是新來的目標c。我試圖創建在我的Mac第一次數據庫我沒有以下步驟無法打開數據庫「test.sql」:無法打開xcode中的數據庫文件

******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

+0

我開始懷疑你有test.sql'稱爲文本文件'和您正試圖使用​​'sqlite3'命令行工具來打開它作爲一個數據庫... – trojanfoe 2012-08-10 09:59:42

+0

雅我得到它比thanx很多trojanfoe – 2012-08-10 10:48:45

回答

0

您可以使用Firefox插件SQLite管理器來創建數據庫。

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

+0

感謝trojanfoe,但即使嘗試了上面給出的內容,錯誤也是一樣的 – 2012-08-10 08:31:55

+1

@MudduPatil你是否在一個有寫權限的目錄中工作? – trojanfoe 2012-08-10 08:38:26

+0

ya我有所有的訪問 – 2012-08-10 09:43:37