sqlite 查看表结构 android.database.sqlite.SQLiteException: table splitTable has no column named

sqlite 插入数据数据时提示没有该列:

android.database.sqlite.sqliteException: table splitTable has no column named isLast (code 1):  

此时可以查看该表的创建结构,然后调整列名称,重新调用插入的方法

Cursor cursor = db.rawQuery("select * from sqlite_master where type= 'table'  and name='" + tableName + "'", null);
/**
 * 查询到结果对应的列名与位置
 * 0 = "type"
 * 1 = "name"
 * 2 = "tbl_name"
 * 3 = "rootpage"
 * 4 = "sql"
 **/
if (cursor.movetoNext()){
  String sql = cursor.getString(cursor.getColumnIndex("sql"));
  Log.d(TAG, "showCreateTable: sql " + sql);
}

 

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能