# Castor DDL Generator - An Introduction

Describes how to use the DDL Generator, and what features and options are currently supported.

Castor DDL Generator creates SQL scripts to drop/create tables, unique keys, sequences and so on based on the input of a Castor JDO mapping file.

    java org.castor.ddlgen.Main -m mapping.xml

This will generate the SQL script mapping.sql in the same directory mapping.xml is located.

## DDL Generator Options

The DDL Generator has a number of different options which may be set. Some of them are specified at the command line while others need to be configured through a property file. Most of the options are located in global properties file `org/castor/ddlgen/ddlgen.properties`, but there are also some options that are specific for one database engine. These DB-specific properties can be found at `org/castor/ddlgen/engine/<database>/<database>.properties`.

### Command Line Options

Command line options

Option | Args | Description | Optional?
--- | --- | --- | ---
m | filename | Castor JDO mapping file to generate DDL for. | Required
o | filename | Name of file the generated DDL will be written to. If not specified the generated DDL will be written to a file named similar as the Castor JDO mapping source file with xml extension being replaced by sql. | Optional
e | database engine | Name of database engine to generate DDL for. The engine used as default can be specified with `org.castor.ddlgen.DefaultEngine` option of global properties file. | Optional
c | filename | Alternative global properties file to be used when generating DDL. | Optional
d | filename | Alternative database specific properties file to be used when generating DDL. | Optional
h |  | Shows help/usage information. | Optional

## Database Engines

The DDL Generator supports generation of SQL scripts for the following database engines:

Description of the attributes

Name | Database engine | Property file
--- | --- | ---
db2 | DB/2 | org/castor/ddlgen/engine/db2/db2.properties
derby | Apache Derby | org/castor/ddlgen/engine/derby/derby.properties
hsql | Hypersonic SQL | org/castor/ddlgen/engine/hsql/hsql.properties
mssql | Microsoft SQL Server | org/castor/ddlgen/engine/mssql/mssql.properties
mysql | MySQL | org/castor/ddlgen/engine/mysql/mysql.properties
oracle | Oracle | org/castor/ddlgen/engine/oracle/oracle.properties
pointbase | Borland Pointbase | org/castor/ddlgen/engine/pointbase/pointbase.properties
postgresql | PostgreSQL | org/castor/ddlgen/engine/postgresql/postgresql.properties
sapdb | SAP DB / MaxDB | org/castor/ddlgen/engine/sapdb/sapdb.properties
sybase | Sybase | org/castor/ddlgen/engine/sybase/sybase.properties