Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite FMDB creating table - beginner iOS

Tags:

sqlite

ios

fmdb

I think this is a simple question but I didnt find the answer in the FMDB git page. When you use the command:

[database executeUpdate:@"create table T_table(name text primary key, age int)"];

does FMDB or SQLite make some kind of verification to see if the table already exists?

Can I call this method in my class initializer without creating more than one table?

Sorry if stupid question.

like image 757
pedros Avatar asked Nov 06 '12 00:11

pedros


1 Answers

Another solution is to change your query to:

create table if not exists test_table (test_no NUMBER, test_name TEXT);

or, you can check for the existence with:

select sql from SQLITE_MASTER where name = 'test_table'

And see if you get any results back.

like image 83
ccgus Avatar answered Nov 02 '22 22:11

ccgus