sho*_*_sm 1 database android populate cordova
我试图避免填充数据库,如果数据库存在,但当我尝试在我的代码中取消此行时,我得到"错误处理SQL:1"
tx.executeSql('DROP TABLE IF EXISTS DEMO');
Run Code Online (Sandbox Code Playgroud)
这是我的整个填充功能
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, word TEXT NOT NULL');
tx.executeSql('INSERT INTO DEMO (id, word) VALUES ("1", "Apple")');
tx.executeSql('INSERT INTO DEMO (id, word) VALUES ("2", "Orange")');
}
Run Code Online (Sandbox Code Playgroud)
为什么不用
CREATE TABLE IF NOT EXISTS DEMO (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, kword TEXT NOT NULL, eword TEXT NOT NULL, pronoun TEXT NOT NULL, level INTEGER NOT NULL)
Run Code Online (Sandbox Code Playgroud)