DBIx::Table::Dup - Perl module to (return SQL to) create duplicate copy of table
use DBIx::Table::Dup; sub mktmptbl { my $src_table = shift; my $date = lc `date +%b_%d_%H_%M_%S`; chomp $date; "${src_table}_$date"; } $dup_tbl_name = mktmptbl($src_tbl_name); # 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, "Type=InnoDB");
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.
$dbh
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).
this
$src
$dup
$create
$append
T. M. Brannon <tbone@cpan.org>
perl. DBIx::DBSchema, DBIx::Connect
To install DBIx::Table::Dup, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Table::Dup
CPAN shell
perl -MCPAN -e shell install DBIx::Table::Dup
For more information on module installation, please visit the detailed CPAN module installation guide.