How to Loop & rename MySQL table in Perl

Posted by Nano HE on Stack Overflow See other posts from Stack Overflow or by Nano HE
Published on 2010-04-15T13:33:44Z Indexed on 2010/04/15 13:53 UTC
Read the original article Hit count: 303

Filed under:
|
|
|

Hi, Could you plesae teach me how to Loop & rename MySQL table in Perl. Thanks.

my code snippet attached

use strict; 
use warnings; 
use DBI; 

my $dbh = DBI->connect( 
    'DBI:mysql:database=dbdev;host=localhost', 
    'dbdev', 
    'dbdevpw', 
    { RaiseError => 1, AutoCommit => 1 }, 
); 

my $sql = RENAME TABLE old_table TO new_table; 
my $sth = $dbh->prepare($sql); 

while (<DATA>){ 
    chomp; 
    // How to implement the Rename all the old tables with the while loop.


    $sth->execute(); 
} 

© Stack Overflow or respective owner

Related posts about perl

Related posts about dbi