Class DB2LUWSchemaDDL
java.lang.Object
org.odpi.openmetadata.adapters.connectors.resource.jdbc.ddl.db2luw.DB2LUWSchemaDDL
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
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.
currentSchema= JDBC URL parameter - Db2 has no equivalent way to set an unqualified
name's default schema from the connection string.-
Constructor Summary
ConstructorsConstructorDescriptionDB2LUWSchemaDDL(String schemaName, String schemaDescription, List<DB2LUWTable> tables) -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of DDL statements to define the schema.
-
Constructor Details
-
DB2LUWSchemaDDL
public DB2LUWSchemaDDL(String schemaName, String schemaDescription, List<DB2LUWTable> tables) throws InvalidParameterException - Throws:
InvalidParameterException
-
-
Method Details
-
getDDLStatements
Returns the list of DDL statements to define the schema.- Returns:
- list of statements
-