DOSQLCLONE.PL - Clone a MySQL table from one database to another
dosqlclone.pl cars savecars dosqlclone.pl mydb cars yourdb = dosqlclone.pl mydb cars = savecars dosqlclone.pl mydb cars yourdb savecars
This program allows you to clone a table from one MySQL database to another. You can optionally change the name of the table that is created.
You must always provide the table name to be cloned and the name of the table to be created. The default input database is that associated with the option -inrealm (same as your userid). The default output database is that associated with -outrealm (same as your userid). Thus the minimal command is:
dosqlclone.pl cars savecars
which copies the table 'cars' from the database associated with a realm equal to your userid to the same database and renames the table as 'savecars'.
dosqlclone.pl mydb cars yourdb =
copies the table 'cars' from the database 'mydb' using the access associated with a realm equal to your userid to the database 'yourdb' as 'cars'.
dosqlclone.pl mydb cars yourdb savecars
copies the table 'cars' from the database 'mydb' using the access associated with a realm equal to your userid to the database 'yourdb' as 'savecars'.
Use the -inrealm and -outrealm options to control the realms associated with the input and output database.
This program takes advantage of realm files from DBIx::Connector to find the database connection information. You do not, however, need to have this Perl module installed. Rather, just create the directory $HOME/.db_connactions and create the realm files with your favorite text editor. The format of these is quite simple as you can see from this example:
~> cd .db_connections/ ~/.db_connections> cat test DBD=mysql SERVER=host=ourdhhost.my.company.com USER=readonly PASS=readable DATABASE=payroll
If no fatal errors are detected, the program exits with a return code of 0. Any error will set a non-zero return code.
Written by Terry Gliedt <firstname.lastname@example.org> in 2006-2008 and is copyrighted (C) by Terry Gliedt.