Board index » delphi » Data Base Restructure

Data Base Restructure

The problem: A database is released with version 1 of the system. For
version 2, we have added 3 fields to one of the tables. For version 2.5, we
added another 4 fields.

The solution: A utility that would read a table's metadata and apply updates
as required. In the example above, it would detect that a version 1 table is
missing 7 fields, and would add them. While, on another installation which
was altready version 2, it would only add 4 fields.

Anybody has/has seen something like this?

Robert

 

Re:Data Base Restructure


On Thu, 28 Oct 1999 18:46:17 GMT, "Robert Kaplan" <rkap...@iamerica.net>
wrote:

Quote
>The problem: A database is released with version 1 of the system. For
>version 2, we have added 3 fields to one of the tables. For version 2.5, we
>added another 4 fields.

>The solution: A utility that would read a table's metadata and apply updates
>as required. In the example above, it would detect that a version 1 table is
>missing 7 fields, and would add them. While, on another installation which
>was altready version 2, it would only add 4 fields.

The FieldDefs property of a dataset component can provide you with a list
of all the columns currently in the table. From there, you can dynamically
build an SQL statement using ALTER TABLE to add only as many new columns as
do not already exist in the table. Build the SQL statement in and execute
it from a TQuery.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx

Other Threads