Er, what do you mean by C Syntax -- SQL isn't C? If you meant ANSI SQL syntax,
you could use:
select count(*) from sqlite_master where type='table' and
lower(name)=lower('tablename');
Instead. But since you're accessing a metadata table that only exists in
SQLite, this isn't particularly more standard.
Peter
________________________________
From: Wei Song 2 <[email protected]>
To: [email protected]
Sent: Fri, March 9, 2012 12:36:58 PM
Subject: Re: [sqlite] Building an SQLite Extension: How to check if a table
exists in the database?
I'd like get the result in C Syntax. How can I do it?
Peter Aronson-3 wrote:
>
> 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 <[email protected]>
> To: [email protected]
> 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
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
--
View this message in context:
http://old.nabble.com/Building-an-SQLite-Extension%3A-How-to-check-if-a-table-exists-in-the-database--tp33473784p33474119.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users