NAME
DBIO::Oracle::Introspect - Introspect an Oracle database via all_* views
VERSION
version 0.900007
DESCRIPTION
DBIO::Oracle::Introspect reads the live state of an Oracle database via the all_* data dictionary views (all_tables, all_tab_columns, all_indexes, all_constraints, etc.). Its models are what DBIO::Oracle::Diff compares. DBIO::Oracle::Deploy does not drive that comparison: its diff and upgrade read the live schema and a temporary user through this class.
my $intro = DBIO::Oracle::Introspect->new(
dbh => $dbh,
schema => 'MYUSER',
);
my $model = $intro->model;
Model shape:
{
tables => { $name => { ... } },
columns => { $table => [ { ... }, ... ] }, # primary key columns carry is_pk and pk_position
indexes => { $table => { $name => { ... } } },
foreign_keys => { $table => [ { ... }, ... ] },
primary_keys => { $table => [ $col, ... ] },
unique_constraints => { $table => [ [ $name => \@cols ], ... ] },
views => { $view => { view_name => $view, definition => $sql, columns => \@names, depends_on => \@views } },
}
views holds the defining query of each view (from all_views.text, see DBIO::Oracle::Introspect::Views), which DBIO::Oracle::Diff writes CREATE OR REPLACE VIEW from; the view itself is in tables with kind view.
The order of what the model lists is the same in every session language: names are read in binary order (NLSSORT(name, 'NLS_SORT=BINARY')), not in the NLS_SORT of the session, which would put a_x, aB and Ab in another order under GERMAN. The session itself keeps its own NLS_SORT. Columns and the columns of a key or index follow their position.
The Oracle introspection is built on the all_* data dictionary views, providing sequence detection via trigger inspection, LOB type handling, and other Oracle-specific behaviors.
ATTRIBUTES
schema
Schema (user) name to introspect. Defaults to the current connected user (via SELECT USER FROM DUAL).
schemas
ArrayRef of further schemas (users) to read besides "schema"; by default none. Their tables, columns, indexes and keys are in the model under the key schema.table -- the schema exactly as the dictionary holds it, then a dot, then the table -- the name a source with a table in another schema (table('OWNX.item')) has, and the name DBIO::Oracle::Diff writes as "OWNX"."item". The entry of such a table in tables keeps its bare table_name and its schema. A foreign key reports the table it points to by that key: schema.table for a table of another schema, the bare name for one of "schema". The connected user reads another schema through the all_* views, i.e. as far as it may see it. A schema that does not exist simply has no tables. Everything else (the sequence of a column is schema.sequence as before) is unchanged.
my $model = DBIO::Oracle::Introspect->new(
dbh => $dbh, schemas => ['OWNX'],
)->model;
METHODS
table_columns_info
my \%info = %{ $intro->table_columns_info($key) };
Hashref of normalized per-column metadata. The Oracle override adds the sequence field (populated from BEFORE INSERT trigger inspection) on top of the canonical data_type / size / is_nullable / default_value / is_auto_increment fields. is_nullable is 0 when the column carries not_null or is a primary key column; key membership is checked via "table_pk_info".
table_pk_info
my \@pk_cols = @{ $intro->table_pk_info($key) };
Ordered list of primary key column names, read from the primary_keys section of the model (keyed by table, in the order of the constraint). The columns carry is_pk and pk_position as well; the dedicated section is what this method reads.
table_fk_info
my \@fks = @{ $intro->table_fk_info($key) };
Each FK is a hashref in the normalized contract shape. The Oracle override adds is_deferrable to attrs -- the canonical implementation drops it, and the Oracle storage layer (ALTER SESSION SET CONSTRAINTS = DEFERRED) needs to know whether a constraint is DEFERRABLE.
view_definition
SQL text of the view definition, or undef. Read from all_views (a LONG column, so LongReadLen is raised for the fetch).
NORMALIZED CONTRACT
The canonical DBIO::Introspect::Base contract methods (table_keys, table_columns, table_uniq_info, table_is_view) are inherited unchanged -- the Oracle model uses bare table names as keys and a unique_constraints section, both of which match the canonical shape. The four methods below override the base to surface Oracle-specific data that the canonical model would drop.
SEE ALSO
DBIO::Oracle::Deploy - install, and diff and upgrade, which compare through this class
DBIO::Oracle::Diff - compares two models produced by this class
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.