简体   繁体   English

在Sqlite中创建表之前必须删除表吗?

[英]Do I have to drop the table before creating it in Sqlite?

When I initialize my Sqlite Database I make it as follows: 当我初始化我的Sqlite数据库时,它如下所示:

 var db = window.openDatabase("Database", "1.0", "Cordova Demo", 20000);
 db.transaction(populateDB, errorCB, successCB);
 function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS TimeTable');
tx.executeSql('CREATE TABLE IF NOT EXISTS TimeTable (id  INTEGER PRIMARY KEY      AUTOINCREMENT, Day, Subject, StartingTime, EndingTime)');}

Now, I don't want the table to be dropped every time I call this function. 现在,我不希望每次调用此函数都删除该表。 But when I remove this line: 但是,当我删除此行时:

tx.executeSql('DROP TABLE IF EXISTS TimeTable');

An error shows: 错误显示:

[INFO] Error processing SQL: 1

Is there a solution for this ? 有解决方案吗?

you can try the solution posted there: 您可以尝试在那里发布的解决方案:

phoneGap Android - Populate database once "Error processing SQL:1" phoneGap Android-一次填充数据库“错误处理SQL:1”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有一张桌子,如何根据选项选择下拉菜单从中调用它? - I have a table, how do I call from it based on option select drop-downs? 点击之前我总是要等吗? - Do I always have to wait before clicking? 我必须在下一个 requestAnimationFrame 之前取消 AnimationFrame 吗? - Do I have to cancelAnimationFrame before next requestAnimationFrame? 我是否需要为每个下拉菜单创建单独的Cookie? - Do I have to create separate cookies for every drop down menu? 我是否必须在第一批sqlite db中创建所有表? - Do I have to create all tables at first population of sqlite db? 在返回变量之前,我是否必须将 function 结果分配给变量? - Do I have to assign a function result to a variable before I return it? 如何在创建可读流之前返回对它的引用? - How do I return a reference to a Readable stream before creating it? 如何拖放 html 表格列? - How do I drag/drop html table columns? 如何从 Javascript 中的 SQLite 数据库中获取表数据? - How do i get table data from SQLite Database in Javascript? 为什么这个变量在我执行“函数MyVar(){}”之前有一个值? - Why does this variable have a value before I do “function MyVar() {}”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM