DBIx::DBSchema::Column - Column objects


DBIx::DBSchema::Column - Column objects


  use DBIx::DBSchema::Column;
  #named params with a hashref (preferred)
  $column = new DBIx::DBSchema::Column ( {
    'name'    => 'column_name',
    'type'    => 'varchar'
    'null'    => 'NOT NULL',
    'length'  => 64,
    'default' => '
    'local'   => '',
  } );
  $column = new DBIx::DBSchema::Column ( $name, $sql_type, $nullability, $length, $default, $local );
  $name = $column->name;
  $column->name( 'name' );
  $sql_type = $column->type;
  $column->type( 'sql_type' );
  $null = $column->null;
  $column->null( 'NULL' );
  $column->null( 'NOT NULL' );
  $column->null( '' );
  $length = $column->length;
  $column->length( '10' );
  $column->length( '8,2' );
  $default = $column->default;
  $column->default( 'Roo' );
  $sql_line = $column->line;
  $sql_line = $column->line($datasrc);


DBIx::DBSchema::Column objects represent columns in tables (see the DBIx::DBSchema::Table manpage).


new [ name [ , type [ , null [ , length [ , default [ , local ] ] ] ] ] ]
Creates a new DBIx::DBSchema::Column object. Takes a hashref of named parameters, or a list. name is the name of the column. type is the SQL data type. null is the nullability of the column (intrepreted using Perl's rules for truth, with one exception: `NOT NULL' is false). length is the SQL length of the column. default is the default value of the column. local is reserved for database-specific information.

name [ NAME ]
Returns or sets the column name.

type [ TYPE ]
Returns or sets the column type.

null [ NULL ]
Returns or sets the column null flag (the empty string is equivalent to `NOT NULL')

length [ LENGTH ]
Returns or sets the column length.

default [ LOCAL ]
Returns or sets the default value.

local [ LOCAL ]
Returns or sets the database-specific field.

Returns an SQL column definition.

The data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.

Although the username and password are optional, it is best to call this method with a database handle or data source including a valid username and password - a DBI connection will be opened and the quoting and type mapping will be more reliable.

If passed a DBI data source (or handle) such as `DBI:mysql:database' or `DBI:Pg:dbname=database', will use syntax specific to that database engine. Currently supported databases are MySQL and PostgreSQL. Non-standard syntax for other engines (if applicable) may also be supported in the future.


Ivan Kohler <ivan-dbix-dbschema@420.am>


Copyright (c) 2000 Ivan Kohler Copyright (c) 2000 Mail Abuse Prevention System LLC All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


line() has database-specific foo that probably ought to be abstracted into the DBIx::DBSchema:DBD:: modules.


the DBIx::DBSchema::Table manpage, the DBIx::DBSchema manpage, the DBIx::DBSchema::DBD manpage, the DBI manpage

 DBIx::DBSchema::Column - Column objects