liveBook · Manning

Data definition language

As explained in Test Driven: Practical TDD and Acceptance TDD for Java Developers

A data definition language is a language for declaring and modifying database structures such as tables and columns.

A data definition language (DDL) uses statements to create a database schema. Keeping DDL in SQL script files gives the schema a single representation that can be versioned with the rest of the system. section 6.4.2

SQL scripts are familiar, but integration tests need a way to execute them from Java, and the scripts may not work across different database products. With Hibernate, schema export can instead use mapping documents when the SessionFactory is created. For example, hibernate.hbm2ddl.auto=create-drop enables schema creation and removal for integration tests. Generated columns may differ from hand-written choices, such as using VARCHAR(255) for a String field. section 6.4.2

Figure 6.6. Example directory structure with a set of delta change scripts for creating the database schema incrementally. The four scripts in the directory src/db/deltas will be applied in order according to the numerical prefix.

Numbered delta scripts illustrate how schema changes can be applied incrementally. section 6.4.2

How Test Driven: Practical TDD and Acceptance TDD for Java Developers covers it

How deep it goes
Compares SQL-script execution and Hibernate-generated schemas, including database compatibility and column-type differences.
Examples
Uses SQL schema scripts, numbered delta files, and Hibernate's create-drop setting as schema-creation examples.
What you can do after
Configure integration-test schema creation with Hibernate's hibernate.hbm2ddl.auto=create-drop setting.
How it connects
Connects DDL with database schemas, SQL, version control, Java, JDBC, Hibernate, and integration testing.

Also explained in

Compare how 2 books explain data definition language →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Test Driven: Practical TDD and Acceptance TDD for Java Developers. The section links point to the parts of the book it draws on.