当前位置:首页 > 数据库 > SQlite

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);
}

 


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!