2013-07-08 30 views
-4

嗨,你可以請告訴我如何檢查表名存在於數據庫或電話缺口。 我谷歌它找到這個。如何獲取返回值在數據庫中是否存在檢查表名稱時爲真還是假? (phonegap)

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")'); 
     } 

但是我不知道如何檢查表是否存在或不存在。

+0

'CREATE TABLE IF NOT EXISTS DEMO'這應該滿足您的要求。 –

回答

0

我做了我自己的...使用到此。 ('CREATE TABLE IF NOT EXISTS'''+ CASENAME +'「(id INTEGER PRIMARY KEY AUTOINCREMENT,DocumentName TEXT NOT NULL,DocumentDate INTEGER,DocumentNotes TEXT NOT NULL)');

相關問題