Page 1 of 1

Right way to add column to Sqlite Database?

Posted: Thu 21 Jan 2016 12:41
by ernschd666
Hi,

I have to add a new column (if it not exists) in my Sqlite-Database (already open) and write data into the new column.

What's the right way to do this?
Now I close the query and add the column with ExecSQL:

Code: Select all

ALTER TABLE bla ADD COLUMN blubb
After this I have to disconnect the connection for using the new column.

Is there a better approach?

Thank you.

Re: Right way to add column to Sqlite Database?

Posted: Fri 22 Jan 2016 13:00
by MaximG
After inserting a new column into a table, it is not required to close and then re-open connection to the database. In case of using the UniQuery component, it is enough to close and re-open the query after column insertion:

UniQuery.Close;
UniQuery.Open;

After that, the newly created column will be available using UniQuery.