Apache DB | DdlUtils | for

Home

Section Credits
apache.org > db > ddlutils | PDF
## Welcome to DdlUtils What is DdlUtils Learning more ### What is DdlUtils DdlUtils is a small, easy-to-use component for working with Database Definition (DDL) files. These are XML files that contain the definition of a database schema, e.g. tables and columns. These files can be fed into DdlUtils via its Ant task or programmatically in order to create the corresponding database or alter it so that it corresponds to the DDL. Likewise, DdlUtils can generate a DDL file for an existing database. DdlUtils uses the Turbine XML format, which is shared by Torque and OJB. This format expresses the database schema in a database-independent way by using JDBC datatypes instead of raw SQL datatypes which are inherently database specific. An example of such a file is:
    <?xml version="1.0"?>
    <!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database.dtd">
    <database name="testdb">
      <table name="author">
        <column name="author_id"
                type="INTEGER"
                primaryKey="true"
                required="true"/>
        <column name="name"
                type="VARCHAR"
                size="50"
                required="true"/>
        <column name="organisation"
                type="VARCHAR"
                size="50"
                required="false"/>
      </table>

      <table name="book">
        <column name="book_id"
                type="INTEGER"
                required="true"
                primaryKey="true"
                autoIncrement="true"/>
        <column name="isbn"
                type="VARCHAR"
                size="15"
                required="true"/>
        <column name="author_id"
                type="INTEGER"
                required="true"/>
        <column name="title"
                type="VARCHAR"
                size="255"
                defaultValue="N/A"
                required="true"/>

        <foreign-key foreignTable="author">
          <reference local="author_id" foreign="author_id"/>
        </foreign-key>

        <index name="book_isbn">
          <index-column name="isbn"/>
        </index>
      </table>
    </database>
### Learning more There are essentially two ways to use DdlUtils: In an Ant build script via the task provided by DdlUtils. You can learn more about here. From within your Java program, about which you can learn more here. You're also welcome to join DdlUtils' mailing lists.