5
我正在使用Android SQLite數據庫。我將它從版本1升級到版本2. onUpgrade
方法正在按預期方式調用。SQLite添加具有默認值的列
我的代碼:
sqLiteDatabase.execSQL("ALTER TABLE " + Contracts.DateActivities.TABLE_NAME + " ADD COLUMN " + Contracts.DateActivities.C_GROUP + " INTEGER DEFAULT 0;");
我不斷收到同樣的錯誤:
Caused by: android.database.sqlite.SQLiteException: near "group": syntax error (code 1): , while compiling: ALTER TABLE DateActivities ADD group INTEGER DEFAULT 0
我在做什麼錯?
其他變化我曾嘗試:
sqLiteDatabase.execSQL("ALTER TABLE " + Contracts.DateActivities.TABLE_NAME + " ADD COLUMN " + Contracts.DateActivities.C_GROUP + " INTEGER DEFAULT 0;");
sqLiteDatabase.execSQL("ALTER TABLE " + Contracts.DateActivities.TABLE_NAME + " ADD COLUMN " + Contracts.DateActivities.C_GROUP + " int DEFAULT 0;");
sqLiteDatabase.execSQL("ALTER TABLE " + Contracts.DateActivities.TABLE_NAME + " ADD " + Contracts.DateActivities.C_GROUP + " INTEGER DEFAULT 0;");
我懷疑** Contracts.DateActivities.C_GROUP **是「組」或「組」或「組」 「或...套管無關緊要),這是SQLite的保留關鍵字...並且不能用於列名稱 –
Oooh哇。我沒有意識到這一點。我會嘗試一個變體 – Sababado
這樣做。如果你在評論中寫下了你所說的答案,我會將其標記爲答案 – Sababado