android.database.sqlite.SQLiteException: near "0": syntax error: ALTER TABLE data ADD COLUMN 0 INTEGER -
i new databases.
i trying add columns table, need add columns named "0", "1", "2", etc.. until "94169".
i following error:
05-04 10:12:50.656: e/an droidruntime(2022): fatal exception: main 05-04 10:12:50.656: e/androidruntime(2022): java.lang.runtimeexception: unable start activity componentinfo{com.example.koday/com.example.koday.mainactivity}: android.database.sqlite.sqliteexception: near "0": syntax error: alter table data add column 0 integer 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.activitythread.performlaunchactivity(activitythread.java:1647) 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1663) 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.activitythread.access$1500(activitythread.java:117) 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.activitythread$h.handlemessage(activitythread.java:931) 05-04 10:12:50.656: e/androidruntime(2022): @ android.os.handler.dispatchmessage(handler.java:99) 05-04 10:12:50.656: e/androidruntime(2022): @ android.os.looper.loop(looper.java:130) 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.activitythread.main(activitythread.java:3683) 05-04 10:12:50.656: e/androidruntime(2022): @ java.lang.reflect.method.invokenative(native method) 05-04 10:12:50.656: e/androidruntime(2022): @ java.lang.reflect.method.invoke(method.java:507) 05-04 10:12:50.656: e/androidruntime(2022): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 05-04 10:12:50.656: e/androidruntime(2022): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 05-04 10:12:50.656: e/androidruntime(2022): @ dalvik.system.nativestart.main(native method) 05-04 10:12:50.656: e/androidruntime(2022): caused by: android.database.sqlite.sqliteexception: near "0": syntax error: alter table data add column 0 integer 05-04 10:12:50.656: e/androidruntime(2022): @ android.database.sqlite.sqlitedatabase.native_execsql(native method) 05-04 10:12:50.656: e/androidruntime(2022): @ android.database.sqlite.sqlitedatabase.execsql(sqlitedatabase.java:1763) 05-04 10:12:50.656: e/androidruntime(2022): @ com.example.koday.databasehelper.aggiungi(databasehelper.java:186) 05-04 10:12:50.656: e/androidruntime(2022): @ com.example.koday.mainactivity.oncreate(mainactivity.java:61) 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 05-04 10:12:50.656: e/androidruntime(2022): @ android.app.activitythread.performlaunchactivity(activitythread.java:1611) 05-04 10:12:50.656: e/androidruntime(2022): ... 11 more
this snippet of code causes error:
public void aggiungi() { sqlitedatabase db = this.getwritabledatabase(); (int = 0; < 94170; i++) { db.execsql("alter table data add column " +integer.tostring(i)+" integer"); } db.close(); return; }
legal characters in identifiers
unquoted identifiers can consist of alphanumeric characters in system default character set (utf8), plus characters '_' , '$'. identifiers can start character legal in identifier, including digit.
however, identifier cannot consist entirely of digits because make indistinguishable number. mysql's support identifiers begin number unusual among database systems. if use such identifier, particularly careful if contains 'e' or 'e' because characters can lead ambiguous expressions. example, expression 23e + 14 (with spaces surrounding '+' sign) means column 23e plus number 14, 23e+14? mean same thing, or number in scientific notation? should careful using identifiers such 0x1020 begin 0x because might interpreted hexadecimal constants.
reference : http://www.informit.com/articles/article.aspx?p=377068
kindly consider modifying database design because 94170 columns exceed maximum number of allowed columns. check sqlite limits
Comments
Post a Comment