db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Mark Donaghy" <philip.dona...@gmail.com>
Subject Re: Renaming columns
Date Fri, 12 Jan 2007 17:54:51 GMT
Hi Christoffer,

On 1/12/07, Christoffer Hammarström <kreiger@imcode.com> wrote:
> Hi!
>
> I'm trying to rename and change the type of some columns in MSSQL and
> MySQL databases.
>
> I have tables "templates", "text_docs", and "templates_cref".
>
> "templates" has primary key "template_id", which is referred by foreign
> keys "text_docs.template_id" and "templates_cref.template_id".
>
> What i want to do is to drop the "templates" table, and then rename the
> "template_id" column in "text_docs" and "templates_cref" to
> "template_name". Also, i want to change the "template_id" column and a
> couple of other columns from an integer column to a varchar(80) column,
> and taking their new values from the "simple_name" column corresponding
> to the "template_id" in the dropped "templates" table.
>
> I've found no easy way to accomplish this using the ddlutils API.
>
> I can't call column.setName(newColumnName), because that makes ddlutils
> think that the old column has been removed and a new column has been added.
>
> Perhaps someone could point me to the best way to do this?

I am not a API user. I use the ant tasks of ddlutils and I often do
database dump and restore using xml.

You could simply change the xml that is created using the tasks,

<writeSchemaToFile outputFile="target/dump-schema.xml" />
<writeDataToFile outputFile="target/dump-data.xml" />

Philip

>
> Thanks!
>
> --
> Christoffer Hammarström
> Programmerare, imCMS, http://www.imcode.com/
> kreiger@imcode.com
>
>
>
>
>


-- 
Philip Donaghy
donaghy.blogspot.com del.icio.us/donaghy/philip
Skype: philipmarkdonaghy
Office: +33 5 56 60 88 02
Mobile: +33 6 20 83 22 62

Mime
View raw message