Subject RE: [firebird-support] Re: How to update table structure with SQL?
Author Alan McDonald
> >
> > You could use a component set to sync databases.
> >
>
> Isn't that for syncing data? If that is so, then I certainly do NOT
> want to do that. I cannot touch the existing data in the customer
> tables.
>
> All I really need to do is add new columns to existing tables, or
> create any new tables.
>
> I have Indexes, Triggers, Generators and Procedures worked out. I
> simply DROP them all - then recreate them all with my script. Since
> this does not affect customer data, it works just fine.
>
> But this does not work for tables and columns. There does not seem to
> be any way to check if a table or column exists.
>
> I am currently doing all this stuff in Delphi. ie, I read in the
> metadata (using Delphi), then check, using Delphi, if a table exists.
> If it does, I feed out the ALTER script - if it does not, I feed out
> the CREATE script. It works, but it is a very poor way to do it!
>
> I now need to do the same with columns, and I can do it the same way in
> Delphi, but I would rather do everything with a Firebird SQL statement.
> Much more portable, and probably quicker.

the standard approach offered by many admin tools is a database structure
comparison tool where the result is a script which updates your target
database.
These tools exist for all major databases.
You register 2 copies of your database, a source and a target. Work on your
source. Then compare against your target with a script as the result.
This script is then applied to your target and your production databases.
You're back to where you started.
Good tools do a good and reliable job where the script also takes care of
recreating depended objects.
Alan