Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi can you please tell me how to check table name exist in data base or not

Hi can you please tell me how to check table name exist in data base or in phone gap .
I google it find this .

function populateDB(tx) {
// drop the DEMO table if it exists
tx.executeSql('DROP TABLE IF EXISTS DEMO');
// create DEMO table with columns id and data
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
// insert test data into DEMO table
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
}

But I don't know how to check table exist or not.?
Posted

1 solution

Try:
C#
tx.executeSql('IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Demo') DROP TABLE Demo');
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900