DBIx::Table::Dup - Perl module to (return SQL to) create duplicate copy of table


 use DBIx::Table::Dup;

sub mktmptbl {

    my $src_table = shift;

    "${src_table}_" . DBIx::Table::Dup::date_string;

 $dup_tbl_name = mktmptbl($src_tbl_name);

 my $append = "Type=InnoDB"; 

 # just return the SQL for the table to create. Do not create table
 my $create_sql = DBIx::Table::Dup->this ($dbh, $src_tbl_name, $dup_tbl_name, 0);

 # create the table
 my $create_sql = DBIx::Table::Dup->this ($dbh, $src_tbl_name, $dup_tbl_name, 1);

 # append this to the create string
                  DBIx::Table::Dup->this ($dbh, $src_tbl_name, $dup_tbl_name, 1, $append);



This module duplicates a table in any database that DBIx::DBSchema can read. DBIx::DBSchema is smart enough to know which database you are dealing with simply by looking at the valid $dbh.


this ($dbh, $src, $dup, $create, $append)

this takes the following arguments: $dbh is a database handle to the database with the table you want to duplicate. $src is the name of the table to be duplicated. $dup is the name of the duplicate table. $create is a flag which, if set, will actually create the table. Otherwise the SQL for the table duplication is returned. $append is a string which will be appended to the SQL creation string. This is useful if you have something Mysql-specific (like the InnoDB table type in the SYNOPSIS).


T. M. Brannon <>


perl. DBIx::DBSchema, DBIx::Connect