You got to be a bit careful there, SQLite isn't case-sensitive about table 
names, but sqlite_master will preserve the case from the CREATE TABLE 
statement.  Instead of 


select count(*) from sqlite_master where type='table' and name='tablename';

You need something like 

select count(*) from sqlite_master where type='table' and name='tablename' 
collate nocase;

Peter



________________________________
From: Roger Andersson <r...@telia.com>
To: sqlite-users@sqlite.org
Sent: Fri, March 9, 2012 11:52:31 AM
Subject: Re: [sqlite] Building an SQLite Extension: How to check if a table 
exists in the database?

On 03/09/12 19:39, Wei Song wrote:
> Hello,
>
> I'm developing an SQLite extension which uses a function to set data into a 
>table. I'd like to know how to check if a table exists in a database?
>
It's hard to say what you need but maybe
select count(*) from sqlite_master where type='table' and name='tablename';
/Roger
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to