On 2016/07/29 10:48 PM, Andrew Stewart wrote:
Have resolved this. I only need a simple statement for adding the new column.
ALTER TABLE argusTable1 ADD COLUMN newField INTEGER
Well yes, but this is not always what you want, this adds the column at
the end (actually, IIUC, it only changes the schema, nothing is actually
added until you insert/update some values). Adding to the end may not be
feasible for several reasons, such as wanting a standard layout,
optimizing by keeping larger column-value columns at the end and so on.
Whatever the reason, if you want to change the layout of the table, you
need to do the steps suggested in your first post.
Whether this is the case, or simply for reasons of OCD / Curiosity, I
would really make an effort to solve why the previous did not work.
Are you sure you are not starting an explicit transaction or opening a
prepared statement on the same DB anywhere else during this process?
Using Execute should do all the steps needed to start and finalize every
statement, so an unresolved statement shouldn't be a problem. Any chance
you have shared cache on?
Those steps given previously (below) should work. It's worth solving it
because some future thing you try to do might suffer from the same problem.
Cheers,
Ryan
Hi,
I am having issues when I need to translate a database that
already exists (adding a field). I added the field using SQLiteStudio and it
gives me the commands necessary to translate the database. When I employ these
in my program, I get an error that I do not know how to work around.
The sequence is this:
ALTER TABLE argusTable1 RENAME TO argus_temp_table
CREATE TABLE argusTable1 (tableID INTEGER PRIMARY KEY, newField INTEGER)
INSERT INTO argusTable1 (tableID) SELECT (screenInstanceID) FROM
argus_temp_table
DROP TABLE argus_temp_table
I run all 4 of these statements in separate sqlite3_exec
statements. The first 3 run fine with no issue. When I try doing the 4th one
I get a Table Locked error (6). If I loop to wait for it, it never returns.
As the problem is with the temporary table, I wouldn't think any place else in
my code would be causing this issue.
I have tried running this SQLiteStudio, running each statement
on its own, and there is no issue. Do not know what I am doing wrong.
Following are my Pragmas used:
PRAGMA synchronous = NORMAL
PRAGMA journal_mode = MEMORY
PRAGMA page_size = 2048
PRAGMA cache_size = 100000
PRAGMA temp_store = MEMORY
SQLite version 3.9.2 is what I am using.
Any assistance would be appreciated.
Andrew Stewart
Software Designer
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users