Home > Database > Mysql Tutorial > body text

使用DdlUtils和Ant进行不同数据库之间schema和data的转换

WBOY
Release: 2016-06-07 17:05:43
Original
1308 people have browsed it

在开发过程中常常要用到多种数据库类型,比如项目可能需要支持Oracle, MySQL, MSSQL Server, Derby等等。已经有很多各种各样的小

在开发过程中常常要用到多种数据库类型,,比如项目可能需要支持Oracle, MySQL, MSSQL Server, Derby等等。已经有很多各种各样的小工具可以帮助开发人员进行数据库之间的schema、data转换与同步,DdlUtils 就是其中之一。它可以结合Ant或者程序代码进行数据库schema/data和xml文件的相互转换。

例如,项目开发支持的是MySQL,而为了单元测试的整洁和方便,开发人员决定使用Derby来支持单元测试。DdlUtils就可以把schema和数据从MySQL中导出,变成xml文件,然后根据需要导入到Derby中;反之亦可。显然,这些导出的xml文件也是对于数据库的一个很好的备份。

下面是apache ddlutils官网给出的一个xml的例子,table和column标签里面支持的child和attribute远不止示例中的这些。

DdlUtils包含了3个Ant Task,分别是databaseToDdl, ddlToDatabase以及dumpMetadata。

使用ddlToDatabase的示例:

这个Ant任务创建了一个PostgreSQL数据库,把xml中定义的schema和data导入到数据库中。

使用databaseToDdl的示例:

这个Ant任务把derby数据库中的schema和data导出到xml文件中。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!