NAME

DBIx::DBSchema::Table - Table objects

SYNOPSIS

use DBIx::DBSchema::Table;

$table = new DBIx::DBSchema::Table (
  "table_name",
  "primary_key",
  $dbix_dbschema_colgroup_unique_object,
  $dbix_dbschema_colgroup_index_object,
  @dbix_dbschema_column_objects,
);

$table->addcolumn ( $dbix_dbschema_column_object );

$table_name = $table->name;
$table->name("table_name");

$primary_key = $table->primary_key;
$table->primary_key("primary_key");

$dbix_dbschema_colgroup_unique_object = $table->unique;
$table->unique( $dbix_dbschema__colgroup_unique_object );

$dbix_dbschema_colgroup_index_object = $table->index;
$table->index( $dbix_dbschema_colgroup_index_object );

@column_names = $table->columns;

$dbix_dbschema_column_object = $table->column("column");

@sql_statements = $table->sql_create_table;
@sql_statements = $table->sql_create_table $datasrc;

DESCRIPTION

DBIx::DBSchema::Table objects represent a single database table.

METHODS

new [ TABLE_NAME [ , PRIMARY_KEY [ , UNIQUE [ , INDEX [ , COLUMN... ] ] ] ] ]

Creates a new DBIx::DBSchema::Table object. TABLE_NAME is the name of the table. PRIMARY_KEY is the primary key (may be empty). UNIQUE is a DBIx::DBSchema::ColGroup::Unique object (see DBIx::DBSchema::ColGroup::Unique). INDEX is a DBIx::DBSchema::ColGroup::Index object (see DBIx::DBSchema::ColGroup::Index). The rest of the arguments should be DBIx::DBSchema::Column objects (see DBIx::DBSchema::Column).

new_odbc DATABASE_HANDLE TABLE_NAME

Creates a new DBIx::DBSchema::Table object from the supplied DBI database handle for the specified table. This uses the experimental DBI type_info method to create a table with standard (ODBC) SQL column types that most closely correspond to any non-portable column types. Use this to import a schema that you wish to use with many different database engines. Although primary key and (unique) index information will only be imported from databases with DBIx::DBSchema::DBD drivers (currently MySQL and PostgreSQL), import of column names and attributes *should* work for any database.

new_native DATABASE_HANDLE TABLE_NAME

Creates a new DBIx::DBSchema::Table object from the supplied DBI database handle for the specified table. This uses database-native methods to read the schema, and will preserve any non-portable column types. The method is only available if there is a DBIx::DBSchema::DBD for the corresponding database engine (currently, MySQL and PostgreSQL).

addcolumn COLUMN

Adds this DBIx::DBSchema::Column object.

name [ TABLE_NAME ]

Returns or sets the table name.

primary_key [ PRIMARY_KEY ]

Returns or sets the primary key.

unique [ UNIQUE ]

Returns or sets the DBIx::DBSchema::ColGroup::Unique object.

index [ INDEX ]

Returns or sets the DBIx::DBSchema::ColGroup::Index object.

columns

Returns a list consisting of the names of all columns.

column COLUMN_NAME

Returns the column object (see DBIx::DBSchema::Column) for the specified COLUMN_NAME.

sql_create_table [ DATASRC ]

Returns a list of SQL statments to create this table.

If passed a DBI data source such as `DBI:mysql:database', will use MySQL-specific syntax. PostgreSQL is also supported (requires no special syntax). Non-standard syntax for other engines (if applicable) may also be supported in the future.

AUTHOR

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

COPYRIGHT

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.

BUGS

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

Some of the logic in new_odbc might be better abstracted into Column.pm etc.

SEE ALSO

DBIx::DBSchema, DBIx::DBSchema::ColGroup::Unique, DBIx::DBSchema::ColGroup::Index, DBIx::DBSchema::Column, DBI