java.lang.Object
org.odpi.openmetadata.adapters.connectors.resource.jdbc.ddl.db2luw.DB2LUWSchemaDDL

public class DB2LUWSchemaDDL extends Object
Builds up the definition of a schema, its tables, columns, primary keys, foreign keys and comments, using IBM Db2 for Linux, UNIX and Windows' SQL/SQL-PL dialect.

Db2's DDL diverges from PostgreSQLSchemaDDL and MSSQLSchemaDDL in a few important ways, and is closer to (but not identical to) OracleSchemaDDL:
  • Unlike Oracle, Db2 does support "CREATE SCHEMA" as a genuine namespace-creation statement, so this class does generate one - unlike an Oracle "schema" (a database user, expected to be pre-provisioned by a DBA).
  • Db2 SQL has no "IF NOT EXISTS" clause on CREATE TABLE/CREATE SCHEMA/ALTER TABLE ADD, so idempotency is achieved with Db2's SQL PL equivalent of Oracle's guarded PL/SQL block technique: a compound statement with a CONTINUE HANDLER that swallows SQLSTATE 42710 (duplicate object - covers both CREATE SCHEMA and CREATE TABLE on an existing name) or 42711 (duplicate column, for ALTER TABLE ADD).
  • Unlike Oracle, Db2 does support "COMMENT ON SCHEMA" natively, so a schema description is recorded as a genuine COMMENT ON SCHEMA statement rather than being silently skipped. COMMENT ON TABLE and COMMENT ON COLUMN are also natively supported and, like Oracle's, are idempotent (re-running them simply overwrites the previous comment), so no guard is required for any of the three.
  • Like Oracle, Db2 foreign key constraints support no "ON UPDATE" clause at all (Db2 expects primary keys to be immutable), so only the "ON DELETE" behaviour is generated.
Table names passed to this class are expected to already be schema-qualified (eg "schemaName.tableName"), since - unlike PostgreSQL's currentSchema= JDBC URL parameter - Db2 has no equivalent way to set an unqualified name's default schema from the connection string.