Page 1 of 1

CREATE TABLE PROBLEM

Posted: Fri Jul 15, 2011 9:55 am
by info26
Hi all,

I have a problem with SQLLite when I create a table.

If my sql cod is

CREATE TABLE mytable field....

It works

If I write

CREATE TABLE IF NOT EXISTS mytable fields...

Non viene creata la tabella anche se non esiste.

There is another way to check also if the table exists, or something wrong?

Thank's

Re: CREATE TABLE PROBLEM

Posted: Fri Jul 15, 2011 10:33 am
by Jellicle
SELECT name FROM sqlite_master
WHERE type='table'
ORDER BY name;

sqlite_master is a default (but usually hidden) table in all sqlite databases, apparently.

Re: CREATE TABLE PROBLEM

Posted: Fri Jul 15, 2011 11:51 am
by Klaus
Hi info26,

you can use the build-in function: revDatabaseTableNames(databaseID)
to get a list of ALL tables in a database and then check if your table name is in this list!


Best

Klaus

Re: CREATE TABLE PROBLEM

Posted: Fri Jul 15, 2011 1:49 pm
by Jellicle
Klaus wrote:Hi info26,
you can use the build-in function: revDatabaseTableNames(databaseID)
to get a list of ALL tables in a database and then check if your table name is in this list!
Even better solution :)

Gerry

Re: CREATE TABLE PROBLEM

Posted: Mon Jul 18, 2011 7:33 am
by info26
Than'k all

Mimmo