NAME
DBIO::DB2::Introspect::Columns - Introspect DB2 columns
VERSION
version 0.900007
DESCRIPTION
Fetches column metadata via SYSCAT.COLUMNS. Primary-key membership is determined via SYSCAT.KEYCOLUSE joined with SYSCAT.TABCONST.
METHODS
fetch
my $columns = DBIO::DB2::Introspect::Columns->fetch($dbh, $schema, $tables);
Given the tables hashref from DBIO::DB2::Introspect::Tables, returns a hashref keyed by table name. Each value is an arrayref of column hashrefs in COLNO order.
The normalized fields are the DBIO::Introspect::Base contract that DBIO::Generate reads through table_columns_info (ADR 0013): column_name, data_type, size, not_null, default_value, is_pk, pk_position, and is_auto_increment (set to 1 only for GENERATED ... AS IDENTITY columns).
data_typeis the lower-case type name a result class writes:charforCHARACTER,double precisionforDOUBLE, otherwiseTYPENAMElower-cased (varchar,integer,decfloat,timestamp).sizeis the declared length: a number forCHAR,VARCHAR,BINARY,VARBINARY,GRAPHIC,VARGRAPHIC,CLOB,BLOB,DBCLOB;[precision, scale]forDECIMAL; the fractional-seconds precision forTIMESTAMP; the digits (16 or 34) forDECFLOAT. Absent for a type Db2 declares without one (SMALLINT,INTEGER,BIGINT,REAL,DOUBLE,DATE,TIME,XML,BOOLEAN,LONG VARCHAR), whoseLENGTHin the catalog is its storage length.default_valueis the value: a string without its quotes ('it''s'isit's), a number as its text, and an expression (CURRENT TIMESTAMP,USER,CURRENT DATE, ...) as a SCALAR reference (\'CURRENT TIMESTAMP'), the form DBIO::DB2::DDL writes bare. No default, and an explicitDEFAULT NULL, areundef.
The catalog fields are internal, for DBIO::DB2::Diff and its operations, which render and compare what the catalog holds. They are not part of any contract and no other consumer reads them:
catalog_typeisTYPENAME(CHARACTER,DOUBLE).catalog_sizeisLENGTH-- the storage length for a type declared without one -- withSCALEafter a comma when that is above zero (10,2).TIMESTAMPis the exception, its value isSCALEalone;DECFLOATcarries its digits,LENGTH8 or 16 as 16 or 34.catalog_defaultisDEFAULT, the SQL text of the default ('new'with its quotes,'it''s',0,CURRENT TIMESTAMP). One exception, for aBOOLEAN: a quoted number ('1') is read as the number (1), the form DBIO::DB2::DDL writes for a class value of digits, so the column made by hand withDEFAULT '1'and the one made from its class do not differ;TRUE,FALSEand a quoted word ('true') stay.
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.