Sqlite - No Such Column Error while deleting table from sqlite_sequence

前端 未结 3 2020
悲哀的现实
悲哀的现实 2021-01-27 22:27

I am trying to clear a table that has autoincrement key.

I am trying to do the following, by i get an exception.

protected void clearSqliteSequenceTable         


        
相关标签:
3条回答
  • 2021-01-27 22:47

    Just modify your query

    from

    String query = "delete from sqlite_sequence where name = business";
    

    to

    String query = "delete from sqlite_sequence where name = \'business\' ";
    

    I have tried its working fine :-)

    0 讨论(0)
  • 2021-01-27 23:00

    Your "where" statement of

     name = business
    

    tries to delete from the table sqlite_sequence where the name column equals a hypotheticalbusiness column. If you are trying to delete from sqlite_sequence where the name column contains the value "business", try

    String query = "DELETE FROM sqlite_sequence WHERE name = 'business'";
    
    0 讨论(0)
  • 2021-01-27 23:03

    try this

    protected void clearSqliteSequenceTable(String table) {
        String query = "delete from " + table;
        mDb.execSQL(query);
    }
    
    0 讨论(0)
提交回复
热议问题