OutOfBoundsException
OutOfBoundsException

Reputation: 766

SQLite can't find column named 'x'

I am working with SQLite database and I am facing a problem when comes to insert/remove column of a table.

Simply, I am trying to update the columns of a table called 'Category' in my database.

ALTER TABLE Category RENAME TO Category1;
CREATE TABLE Category (c_id INTEGER PRIMARY KEY AUTOINCREMENT, c_name TEXT, c_prefix TEXT, INT c_parent);
INSERT INTO Category (c_name, c_parent) SELECT name, parent FROM Category1;

but I am getting:

Error: table Category has no column named c_parent

I've also tried to DROP Category table and re-create it (as I know sometimes keeps reference to the old one) without any luck.

All, tables' and columns' names are correct (double-checked).

Any idea how I can make SQLite recognise the new table as the 'Category' one?

Upvotes: 0

Views: 172

Answers (2)

Scott Hunter
Scott Hunter

Reputation: 49803

Your CREATE statement has the type & name of the c_parent column reversed.

Upvotes: 0

StuartLC
StuartLC

Reputation: 107247

You've transposed the type and column name in the last column of your create table, viz

CREATE TABLE Category 
...
c_parent INT )

Once you've confirmed all your data is safely across, you can DROP TABLE Category1

Upvotes: 2

Related Questions