Right way to add column to Sqlite Database?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ernschd666
Posts: 11
Joined: Wed 15 Jul 2015 11:54

Right way to add column to Sqlite Database?

Post by ernschd666 » Thu 21 Jan 2016 12:41

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.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Right way to add column to Sqlite Database?

Post by MaximG » Fri 22 Jan 2016 13:00

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.

Post Reply