That SQL doesn't conform to SQLite's CREATE TABLE
syntax as documented online. If you look at the FMDB lastErrorMessage
method (which is analogous to sqlite3_errmsg
), it will report the specifics regarding the error.
Notably, the AUTO_INCREMENT
syntax is not correct. Even if you fix that, the ENGINE
and DEFAULT CHARSET
options won't be recognized, either. At the very minimum, you'd have to try something like:
NSString *sql = @"CREATE TABLE IF NOT EXISTS `admin` ("
"`admin_id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
"`first_name` varchar(30) NOT NULL,"
"`last_name` varchar(30) NOT NULL,"
"`email` varchar(30) NOT NULL,"
"`password` varchar(30) NOT NULL,"
"`date` datetime DEFAULT NULL,"
"`status` tinyint(2) NOT NULL"
")";
Or, given that SQLite won't understand some of those data types (though with SQLite's "dynamic type system", it doesn't really matter), you might want to replace varchar(30)
with TEXT
and tinyint(2)
with INTEGER
and datetime
with whatever format you plan on storing dates. See Data Types discussion.