How to delete or drop a table in Ionic 2 SqlStorage WebSql

I am trying to delete a table in my database (web database) by using a method like this:

private emptyStorage():void{
        this.platform.ready().then(() => {
           console.log("empty the storage");
           this.storage.query("DROP TABLE IF EXISTS cards"),(data)=>{
               console.log("deleted",data); // never gets printed
           },(error) =>{
               console.log("error deleted",error.err); // never gets printed
           };
        });
    }

I know the table exists because I am able to read data from it by writing 'SELECT * FROM cards' in another query. And I am also able to add items to the table. I can also add that I created the table with this query: 'CREATE TABLE IF NOT EXISTS cards (id INTEGER PRIMARY KEY AUTOINCREMENT, cardId TEXT, name TEXT)'

However, I have not been able to delete the table. Any suggestions on how to delete the entire table?

EDIT: I meant to write TABLE from the beginning, not VIEW. None of them work though :confused:

Views and tables aren’t the same thing. Have you tried “DROP TABLE” instead of “DROP VIEW”?

1 Like

I use DROP TABLE cards

I think I made some mistakes when I opened, added, or dropped the database, Maybe I tried to do all three things at the same time, because now it works if I write DROP TABLE cards.