android – (1)在“AUTO_INCREMENT”附近:更改表时出现语法错误

前端之家收集整理的这篇文章主要介绍了android – (1)在“AUTO_INCREMENT”附近:更改表时出现语法错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试更改定义如下的sqlite表:
String CREATE_TABLE="CREATE TABLE IF NOT EXISTS " + tab_NAME + " ("
                            + row_ID + " INTEGER PRIMARY KEY,"
                            + row_NAME + " TEXT,"
                            + row_EMAIL + " TEXT,"
                            + row_WEBSITE + " TEXT,"
                            + row_TELEPHONE1 + " TEXT,"
                            + row_TELEPHONE2 + " TEXT,"
                            + row_TELEPHONE3 + " TEXT,"
                            + row_TELEPHONE4 + " TEXT,"
                            + row_TELEPHONE5 + " TEXT);";
        db_name.execsql(CREATE_TABLE);

        String newTab="CREATE TABLE IF NOT EXISTS temp ("
                + row_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
                + row_NAME + " TEXT,"
                + row_EMAIL + " TEXT,"
                + row_WEBSITE + " TEXT,"
                + row_TELEPHONE1 + " TEXT,"
                + row_TELEPHONE2 + " TEXT,"
                + row_TELEPHONE3 + " TEXT,"
                + row_TELEPHONE4 + " TEXT,"
                + row_TELEPHONE5 + " TEXT);";
        db_name.execsql(newTab);

这是auto_increment alter语句:

String alter="ALTER TABLE temp AUTO_INCREMENT=1;";
    ourDatabase.execsql(alter);

我在(1)AUTO_INCREMENT附近收到错误:语法错误

怎么了??任何帮助?

解决方法

sqlite中,声明为INTEGER PRIMARY KEY的列将自动自动递增.删除AUTOINCREMENT关键字,然后尝试.

检查SQLite FAQ

原文链接:https://www.f2er.com/android/316812.html

猜你在找的Android相关文章