SQLite issue with Table Names using numbers?

纵然是瞬间 提交于 2019-12-01 01:37:29

问题


I'm developing an app which requires that the user selects a year formatted like this 1992-1993 from a spinner. The tablename is also named 1992-1993 and the idea is that using SQL the values from this table are pulled through with a statement like this select * from 1992-1993. When I run the emulator however, it throws an error.

If I then relabel the Spinner item to NinetyTwo and rename the table to NinetyTwo and run the emulator it runs as expected and the data is pulled through from the table.

Does SQLite have an issue with numbers in table names?


回答1:


Yes and No. It has an issue with numbers at the beginning of a table name. 1992-1993 is an expression returning -1. Try to rename the table to Year1992.

Here a similar issue on SO.




回答2:


sorry for late post

There may be a deeper issue here - is the structure you are using (table name per item in spinner) the best one for the job?

You may find that you want a number of tables e.g.

spinner_value (id, value) form_data(id, spinner_value_id, etc ....)



来源:https://stackoverflow.com/questions/4007780/sqlite-issue-with-table-names-using-numbers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!