Fin Springs wrote:
> 
> I have been using:
> 
> SELECT NULL FROM sqlite_master WHERE type='table' AND lower(name)=?
> 
> to determine whether a table exists and looking at the number of rows
> returned (I'm using sqlite3_get_table through an API). I get one row
> back if the table exists and no rows when it doesn't. There wouldn't be
> multiple rows to LIMIT in this case though.
> 
> Is that bad?

It isn't good or bad, just different.

Your application has to perform the extra logic of counting the returned 
rows to determine existence. If you use a subselect and exists, SQLite 
will effectively do that for your application and return a boolean value 
directly.

select exists (SELECT * FROM sqlite_master WHERE type='table' AND 
lower(name)=?)

This will always return one row with one column with a value that is 
either 0 or 1.

HTH
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to