Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 735301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:28:24+00:00 2026-05-14T07:28:24+00:00

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

  • 0

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(); 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:28:25+00:00Added an answer on May 14, 2026 at 7:28 am

    This code can be used to rename all tables in the database:

    my @tables = map @$_, @{ $dbh->selectall_arrayref('SHOW TABLES') };
    
    for my $table (@tables) {
        $dbh->do("RENAME TABLE $table TO new_${table}");
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please suggest why this is happening... I’ve got some code to pretty
Could you please check out this piece of code: #include <vector> class A {
In Mathematica, do I have to use an explicit loop to calculate the product
The code below produces t1 t1 t2. I wondered if someone could please tell
I'm basically trying to teach myself how to code and I want to follow
PROBLEM: Ok, I've been TRYING to follow the sample code on the MySQL Forge
Could anyone please teach me to extract info out of html in C#? I'm
I have a small problem, looked here & other forums, but could not find
could someone please teach me a common example whereby (!) you destroy the stack
Could please show me code how to get this type of effect? I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.