NAME

DBIO::MSSQL::Introspect - Introspect a Microsoft SQL Server database via information_schema

VERSION

version 0.900004

DESCRIPTION

DBIO::MSSQL::Introspect reads the live state of a Microsoft SQL Server database via the standard SQL INFORMATION_SCHEMA views. It is the source side of the test-deploy-and-compare strategy used by DBIO::MSSQL::Deploy.

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

Model shape mirrors DBIO::SQLite::Introspect:

{
    tables       => { $name => { ... } },   # a view: kind => 'view', definition
    columns      => { $table => [ { ... }, ... ] },
    indexes      => { $table => { $name => { ... } } },
    foreign_keys => { $table => [ { ... }, ... ] },
    collation    => { name => '...', case_sensitive => 0|1 },
    schemas      => { $schema => { schema_name => $schema } },
}

A table of the schema "schema" (dbo) is keyed by its bare name; the tables of the other schemas asked for with "schemas" are keyed schema.table. schemas lists the schemas asked for that exist in the database.

collation is the collation of the database the handle is connected to: the one that decides whether Foo and foo are the same name for a table, column, index or constraint. case_sensitive is read from the ComparisonStyle of the collation (bit 1 set: case is ignored), so a binary collation (..._BIN2) is case-sensitive too. DBIO::MSSQL::Diff compares names by the collation of its source model.

ATTRIBUTES

schema

Schema name to introspect. Defaults to dbo. Its tables are keyed by their bare name in the model.

schemas

my $intro = DBIO::MSSQL::Introspect->new(dbh => $dbh, schemas => ['other']);

More schemas to introspect besides "schema", default none. Their tables, columns, indexes and foreign keys are keyed schema.table in the model, and a foreign key that references a table of another schema than "schema" says schema.table in to_table (to_schema carries the schema on its own). A schema that does not exist is not an error: it has no tables and is not listed in the schemas section. DBIO::MSSQL::Deploy passes the schemas the classes name.

NORMALIZED INTROSPECTION CONTRACT

The seven DBIO::Introspect::Base contract methods (table_keys, table_columns, table_columns_info, table_pk_info, table_uniq_info, table_fk_info, table_is_view) are inherited unchanged from the base: they are pure reads over the canonical model this class builds, so this introspector serves as a high-fidelity source for DBIO::Generate with no driver-specific override. Two model details make the defaults correct here: DBIO::MSSQL::Introspect::Columns emits the canonical is_auto_increment flag (alongside the MSSQL-native is_identity), and DBIO::MSSQL::Introspect::Indexes already excludes primary-key indexes, so table_uniq_info never double-reports the PK.

SEE ALSO

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.