NAME

DBIO::DB2::Introspect - Introspect a DB2 database via SYSCAT

VERSION

version 0.900007

DESCRIPTION

DBIO::DB2::Introspect reads the live state of a DB2 database via SYSCAT, returning a unified model hashref. It is the source side of the test-deploy-and-compare strategy used by DBIO::DB2::Deploy.

my $intro = DBIO::DB2::Introspect->new(dbh => $dbh);
my $model = $intro->model;

Model shape mirrors DBIO::DuckDB::Introspect:

{
    tables             => { $name => { ... } },   # a view also has view_definition
    columns            => { $table => [ { ... }, ... ] },
    indexes            => { $table => { $name => { ... } } },   # incl. the PK index, origin 'pk'
    foreign_keys       => { $table => [ { ... }, ... ] },
    unique_constraints => { $table => [ [ $name, \@columns ], ... ] },
}

unique_constraints is the optional section of the DBIO::Introspect::Base contract (ADR 0009). The index Db2 keeps behind a UNIQUE constraint is part of the constraint and not in indexes.

ATTRIBUTES

schema

DB2 schema to introspect. Defaults to USER (current user's schema).

METHODS

table_uniq_info

The UNIQUE constraints, then the unique indexes made with CREATE UNIQUE INDEX (the index behind the primary key is in the model with origin => 'pk', and left out here, ADR 0011).

table_fk_info

table_is_view

NORMALIZED CONTRACT

The DBIO::Introspect::Base contract used by DBIO::Generate is satisfied by the base-class defaults: the native model built by _build_model already uses the canonical shape (bare table-name keys; columns with column_name/data_type/size/not_null/default_value/is_pk/ pk_position/is_auto_increment in the normalized form DBIO::DB2::Introspect::Columns describes -- lower-case data_type, the declared size (absent for a type Db2 declares without one), the default_value as a value or a SCALAR reference for an expression -- plus the internal catalog_type/catalog_size/catalog_default that only the diff reads (ADR 0013); indexes with origin marking the PK index; tables with kind). So table_keys, table_columns, table_columns_info, table_pk_info, table_uniq_info and table_is_view are inherited unchanged.

table_fk_info and table_uniq_info are overridden: DB2 carries the constraint name and the referenced schema, which the generic default drops; and the base takes the unique_constraints section as the whole answer, which here would lose the unique indexes of db2_indexes.

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.