Q:

Alter column name?

I have a table "Items" with different columns but I didn't asign a name in each column. Now I have different rows in this table and I would like to execute:
ItemsDao.queryBuilder().where().eq(Items.NAME, "computer").query();

But my column doesn't have name. I have tried to update my table with "alter table" but it doesn't work.
AnyBody know how I can add a name of my column without lost my information?
Thank you

A:

Edit:
Sorry, now I understand the question.  You are saying that you did not specify a columnName = "..." for each of your fields and you are having problems with QueryBuilder now because of this.
You don't need a columnName to get QueryBuilder to work although it is recommended.  You should be able to go back to fields and add a columnName static that matches your existing schema.  For example, if the field in the database is "items" then you just add the columnName = "items" to your Java field.  I don't believe Sqlite is case sensitive with regards to column names but it would be good to match the case as well.
But you don't need the columnName.  If you field name in the database is "items" then you should be able to do:
itemsDao.queryBuilder().where().eq("items", "computer").query();

If you edit your question to show your schema and the exception you are getting from QueryBuilder, I'll be able to respond more specifically.

I believe you should be able to do:
 dao.executeRaw("ALTER TABLE `items` ADD COLUMN name VARCHAR;");

That doesn't work for you?  There is a section in the ORMLite documentation about updating your schema under Android:

http://ormlite.com/docs/upgrade-schema

To quote from it, you will need to change your database version when you make schema changes and then in your onUpgrade(...) method do something like:
Dao<Account, Integer> dao = getHelper().getAccountDao();
// change the table to add a new column named "age" 
dao.executeRaw("ALTER TABLE `account` ADD COLUMN age INTEGER;");

Most likely you will be keying off the database version number do if they have version 1 you do X and Y but if they have version 2 you just do Y.  Something like that:
if (oldVersion == 1) {
  // we added the age column in version 2
  dao.executeRaw("ALTER TABLE `account` ADD COLUMN age INTEGER;");
}
if (oldVersion < 2) {
  // we added the weight column in version 3
  dao.executeRaw("ALTER TABLE `account` ADD COLUMN weight INTEGER;");
}

You are limited by Sqlite on what you can do with ALTER TABLE.  Right now you can only rename a column or add a new column. See the docs for more details.

