How to delete a database in WebSQL programmatically?

后端 未结 9 979
执念已碎
执念已碎 2020-12-25 10:03

I am new to Web SQL database and I use it to save data in a local database in a web page.

 I can create a database

9条回答
  •  有刺的猬
    2020-12-25 10:20

    Please note that if you use multiple

    tx.executeSql('DROP TABLE mytable'); 
    

    statements in the same transaction callback then make sure that they all exist or consider using DROP TABLE IF EXISTS syntax instead. If even one table doesn't exist when you try to drop it will result in the entire transaction failing. This failure results in a rollback of the transaction and means that the data will stay in your database even when you thought that it should have been deleted. There is no error reported unless you're specifically listening for it in the executeSql's 4th argument which is an error callback. This is intended behavior but is, in my experience, confusing.

提交回复
热议问题