標籤:
SQLite 的官網
http://addons.mozillan.org/firefox/addon/sqlite-manager/
http://www.sqlite.org
sqlite3 *sqlite = nil;
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/data.file" ];
//開啟資料庫
int result = sqlite3_open([filePath UTF8String], &sqlite);
if (result !=SQLITE_OK) {
NSLog(@"建立失敗!!!");
return ;
}
//建立表的SQL語句
NSString *sql = @"CREATE TABLE IF NOT EXISTS UserTable(userName text PRIMARY KEY ,password text,email text)";
//執行SQL語句
char *error;
result = sqlite3_exec(sqlite, [sql UTF8String], NULL, NULL, &error);
if (result != SQLITE_OK) {
NSLog(@"建立資料庫失敗:%s",error);
return ;
}
//插如入一條資料
//INSERT OR REPLACE INTO UserTable (userName,password,email) VALUES(?,?,?);
//更新一條資料
//UPDATE UserTable set password = ‘‘ where userName = ‘‘;
//查詢資料
//SELECT userName ,password,eamil FROM UserTable where username = ‘‘;
//刪除資料
// DELETE FROM UserTable WHERE username =‘‘;
//關閉資料庫
sqlite3_close(sqlite);
SQLite 粗劣內容