//删除web sql数据表
function btnClearDBtable(tbName){
db = openDB();
if(db){
var strSQL="drop table "+tbName;
db.transaction(function(tr) {
tr.executeSql(strSQL,[],
function(tr,re){
console.log("删除了"+tbName+"表");
},
function(tr,er){
console.log("删除"+tbName+"表失败,错误信息:"+er.message);
});
}
);
}
}
//初始化
var db = null;
var dbName = "mydb"; //数据库名
var version = "1.0"; //版本数据
var description = "Test DB"; //描述
var maxSize = 1024 * 1024 * 1024; //最大值
//打开or连接web sql数据库
function openDB() {
try {
if (!db) {
db = openDatabase(dbName,version,description,maxSize);
if(!db){
alert('你的浏览器不支持HTML web SQL本地数据库!');
return ;
}
}
} catch (e) {
db = null;
}
return db;
}