db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Dudziak" <tom...@gmail.com>
Subject Re: Adding a new column in an existing table using the API
Date Tue, 25 Sep 2007 06:48:47 GMT
On 9/23/07, robk99 <ROBEKLEIN@tx.rr.com> wrote:

> Is there a method using the API to modify an existing table by adding a
> column to it without deleting the original table and then recreating the
> table with the new column?

That's pretty much what DdlUtils is made for. It involves basically three steps:

* Read the database model from either the live database (via the
readModelFromDatabase method in the Platform instance that you'll get
from the PlatformFactory) or an XML file (via the DatabaseIO class).

* Change the mode which is basically a bunch of objects representing
tables, columns, foreign keys etc. E.g. in your case, find the table
in question and simply add a column to it.

* Write the database model to an XML file (again via the DatabaseIO
class) or to the live database (using the alterTables method in the

You could also use a variations of the above to get SQL for the
alteration that you then could execute manually.


View raw message