You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by "Jean T. Anderson" <jt...@bristowhill.com> on 2006/03/11 00:35:56 UTC

DdlUtils example for Derby

Every now and then there are posts to the derby-user list about how to
migrate databases to Derby, so I added a writeup to the Derby site on
how to use DdlUtils to migrate databases to Derby:

   http://db.apache.org/derby/integrate/db_ddlutils.html

I'd appreciate any corrections or improvements you could suggest.

regards,

-jean

Re: DdlUtils example for Derby

Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Thomas Dudziak wrote:
> On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:
...
>>>* Instead of using ";create=true" you could use the createDatabase
>>>subtask (with failOnError=false) which has the advantage that it hides
>>>the DB-specific details of creation.
>>
>>ok, I'll try that.  When I initially used the createDatabase subtask I
>>got an error, but I was fumbling quite a bit and assumed it wasn't
>>supported for Derby. I'll try again.
> 
> 
> Creation is supported, but not dropping (there is no drop=true).

oh, yes, very nice -- thank you! This eliminates the warning with the
derby create=true flag.

-jean

Re: DdlUtils example for Derby

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:

> > * One important thing that you should note is that the model uses only
> > JDBC datatypes. This is a 'limitation' which might bite a few people,
> > espcially when the driver is old (and for instance reports OTHER
> > instead of something useful) or the database has a somewhat different
> > type concept (such as Oracle's NUMBER type).
>
> Thanks -- how "old" creates a problem?

This depends on the DB. E.g. a pre-3 MySql driver will produce *bad*
results as would any Microsoft SqlServer driver except the recently
released 2005 one. Same for pre-8 Oracle drivers.
With most databases, you can use the newest driver available, even if
not directly associated to your DB version. E.g. the 10g driver will
work just nicely with an Oracle 8 database.

> > * Instead of using ";create=true" you could use the createDatabase
> > subtask (with failOnError=false) which has the advantage that it hides
> > the DB-specific details of creation.
>
> ok, I'll try that.  When I initially used the createDatabase subtask I
> got an error, but I was fumbling quite a bit and assumed it wasn't
> supported for Derby. I'll try again.

Creation is supported, but not dropping (there is no drop=true).

> > * The database name (when writing a schema to XML) is derived from the
> > schema name in the db. If there is none (as for Derby), currently null
> > is used (which is not written to XML). I'll fix that tomorrow :-)
>
> So DdlUtils will automatically fill in that name in the schema file?
> i.e., I manually added it:
>
>    <database name="MigrateTest">

For Oracle this already works because it returns the schema name in
the JDBC metadata. For other databases I will simply add an attribute
to the task or use a default string.

cheers,
Tom

Re: DdlUtils example for Derby

Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Thomas Dudziak wrote:
> On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:
> 
> 
>>>* The database name (when writing a schema to XML) is derived from the
>>>schema name in the db. If there is none (as for Derby), currently null
>>>is used (which is not written to XML). I'll fix that tomorrow :-)
>>
>>So DdlUtils will automatically fill in that name in the schema file?
>>i.e., I manually added it:
>>
>>   <database name="MigrateTest">
> 
> 
> I've updated the website - including the documentation of the Ant
> tasks. The DatabaseToDdlTask now has a modelName attribute that
> specifies the name of the database in the XML:
> 
> http://db.apache.org/ddlutils/ant-tasks.html#DatabaseToDdlTask+reference


thanks!

 -jean


Re: DdlUtils example for Derby

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/13/06, Guy Davis <da...@guydavis.ca> wrote:

> Please close DDLUTILS-74 as this issue and patch submitted last month
> are essentially what you did below.

Thanks for pointing it out (I wanted to go through the issues once the
db alteration stuff is finished).

cheers,
Tom

Re: DdlUtils example for Derby

Posted by Guy Davis <da...@guydavis.ca>.
Hi Thomas,

Please close DDLUTILS-74 as this issue and patch submitted last month 
are essentially what you did below.

Guy

Thomas Dudziak wrote:
> On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:
> 
> 
>>>* The database name (when writing a schema to XML) is derived from the
>>>schema name in the db. If there is none (as for Derby), currently null
>>>is used (which is not written to XML). I'll fix that tomorrow :-)
>>
>>So DdlUtils will automatically fill in that name in the schema file?
>>i.e., I manually added it:
>>
>>   <database name="MigrateTest">
> 
> 
> I've updated the website - including the documentation of the Ant
> tasks. The DatabaseToDdlTask now has a modelName attribute that
> specifies the name of the database in the XML:
> 
> http://db.apache.org/ddlutils/ant-tasks.html#DatabaseToDdlTask+reference
> 
> cheers,
> Tom


Re: DdlUtils example for Derby

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:

> > * The database name (when writing a schema to XML) is derived from the
> > schema name in the db. If there is none (as for Derby), currently null
> > is used (which is not written to XML). I'll fix that tomorrow :-)
>
> So DdlUtils will automatically fill in that name in the schema file?
> i.e., I manually added it:
>
>    <database name="MigrateTest">

I've updated the website - including the documentation of the Ant
tasks. The DatabaseToDdlTask now has a modelName attribute that
specifies the name of the database in the XML:

http://db.apache.org/ddlutils/ant-tasks.html#DatabaseToDdlTask+reference

cheers,
Tom

Re: DdlUtils example for Derby

Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Thomas Dudziak wrote:
> On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:
> 
> 
>>Every now and then there are posts to the derby-user list about how to
>>migrate databases to Derby, so I added a writeup to the Derby site on
>>how to use DdlUtils to migrate databases to Derby:
>>
>>   http://db.apache.org/derby/integrate/db_ddlutils.html
>>
>>I'd appreciate any corrections or improvements you could suggest.
> 
> 
> Thanks Jean! I just saw it on the derby-user list, and it looks great.
> Just a few minor comments:
> 
> * One important thing that you should note is that the model uses only
> JDBC datatypes. This is a 'limitation' which might bite a few people,
> espcially when the driver is old (and for instance reports OTHER
> instead of something useful) or the database has a somewhat different
> type concept (such as Oracle's NUMBER type).

Thanks -- how "old" creates a problem?

> * Instead of using ";create=true" you could use the createDatabase
> subtask (with failOnError=false) which has the advantage that it hides
> the DB-specific details of creation.

ok, I'll try that.  When I initially used the createDatabase subtask I
got an error, but I was fumbling quite a bit and assumed it wasn't
supported for Derby. I'll try again.

> * The database name (when writing a schema to XML) is derived from the
> schema name in the db. If there is none (as for Derby), currently null
> is used (which is not written to XML). I'll fix that tomorrow :-)

So DdlUtils will automatically fill in that name in the schema file?
i.e., I manually added it:

   <database name="MigrateTest">

> I'll plan on updating the website tomorrow (there have been a couple
> of changes).

thanks!

 -jean


> cheers,
> Tom


Re: DdlUtils example for Derby

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/11/06, Jean T. Anderson <jt...@bristowhill.com> wrote:

> Every now and then there are posts to the derby-user list about how to
> migrate databases to Derby, so I added a writeup to the Derby site on
> how to use DdlUtils to migrate databases to Derby:
>
>    http://db.apache.org/derby/integrate/db_ddlutils.html
>
> I'd appreciate any corrections or improvements you could suggest.

Thanks Jean! I just saw it on the derby-user list, and it looks great.
Just a few minor comments:

* One important thing that you should note is that the model uses only
JDBC datatypes. This is a 'limitation' which might bite a few people,
espcially when the driver is old (and for instance reports OTHER
instead of something useful) or the database has a somewhat different
type concept (such as Oracle's NUMBER type).

* Instead of using ";create=true" you could use the createDatabase
subtask (with failOnError=false) which has the advantage that it hides
the DB-specific details of creation.

* The database name (when writing a schema to XML) is derived from the
schema name in the db. If there is none (as for Derby), currently null
is used (which is not written to XML). I'll fix that tomorrow :-)

I'll plan on updating the website tomorrow (there have been a couple
of changes).

cheers,
Tom