Subject Re: [firebird-support] How to update table structure with SQL?
Author Flávio Costa
You could use a component set to sync databases.

On Mon, Jun 22, 2009 at 22:09, neighbour.kerry<kerry@...> wrote:
>
>
> I am a fairly new user to Firebird, but have used SQL Server and DBISAM for
> years (in Delphi).
>
> What I want to do is update my customers' tables to the same level as my
> master development database. What I have done on other databases is
> something along the lines of
>
> CREATE table if not exists "activefilestorage" ("ID" autoinc, "StorageArea"
> VARCHAR (30), "NoOfFiles" integer DEFAULT 0, "OfficeID" integer DEFAULT 0);
>
> ALTER TABLE if EXISTS "activefilestorage" ADD COLUMN if not EXISTS "ID"
> autoinc;
>
> Ok - so I want to create a table if it does not exist. Then I want to add
> columns if they do not exist. All fairly normal, but it seems to be a real
> problem in Firebird.
>
> I generate this script in Delphi - I scan my local database, look at every
> table, and all the columns, indexes, etc, then generate this script. I then
> send it out to customers, they run it - and their database is updated. Good
> plan!
>
> I have it all working fairly well - if they have no tables at all it works
> just fine. But Firebird has a terrible time altering and adding columns, and
> as far as I can see, does not have any IF EXISTS function.
>
> I cannot simply DROP tables, and recreate them (which would work), as the
> customers would lose their data.
>
> Can anyone point me in the right direction?
>
>