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 7158633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:05:55+00:00 2026-05-28T13:05:55+00:00

Here is a pretty simple code : $query = RENAME TABLE myOldTableName TO myNewTableName;

  • 0

Here is a pretty simple code :

$query = "RENAME TABLE myOldTableName TO myNewTableName";
$is_ok = mysql_query($query);
echo ($is_ok) ? "Rename OK" : "Rename aborted";

But it alwayls print “Rename aborted”.

I found on php.net :

When processing a RENAME TABLE query, PHP apparently always returns false, 
no matter if the query was successfully processed or not.

I tried mysql_affected_rows, but not working..
Any idea to know if the rename worked or not ? (without another query like SELECT, or SHOW TABLES, etc).

Thanks !

  • 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-28T13:05:56+00:00Added an answer on May 28, 2026 at 1:05 pm

    Well, after many tests, here we are :

    RENAME TABLE `mytable_a` TO `mytable_b`
    mysql_query           :  bool(true)
    mysql_affected_rows() :  int(0)
    mysql_info()          :  bool(false)
    
    RENAME TABLE `tableNotExists` TO `FooBar`
    mysql_query           :  bool(false)
    mysql_affected_rows() :  int(-1)
    mysql_info()          :  bool(false)
    
    ALTER TABLE `mytable_b` CHANGE `fieldFOO` `fieldBAR` INT(11) NOT NULL
    mysql_query           :  bool(true)
    mysql_affected_rows() :  int(42053)
    mysql_info()          :  string(42) "Records: 42053 Duplicates: 0 Warnings: 0"
    
    ALTER TABLE `mytable_b` CHANGE `fieldNotExists` `newName` INT(11) NOT NULL
    mysql_query           :  bool(false)
    mysql_affected_rows() :  int(-1)
    mysql_info()          :  bool(false) 
    

    After all, RENAME TABLE seems to work fine. The comment on php.net is apparently wrong, and I went as wrong as him on my first tests.

    I want to thank Fahim Parkar who put his finger on a solution, and Entropy and Leigh who offer me alternative 😉

    Tell me if something seems wrong !

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

Sidebar

Related Questions

pretty simple issue here, this was working before but not anymore. heres my code:
I'm pretty sure this is a simple question in regards to formatting but here's
I have a pretty simple block of C# code here... static void ReadMSOfficeWordFile(string file)
the php code is pretty simple : <?php $my_bn_num=number_bangla(0123); function number_bangla($num1){ echo (<br>num =.$num1);
Pretty simple task, but the source code doesn't do required job... Please advise. There
Pretty simple question, but can't seem to find a complete answer on here... I
I want to achieve a pretty simple task, but none of the solutions here
Well, I'm gonna be pretty straightforward here, I just have a piece of code
I hate to have to ask, but I'm pretty stuck here. I need to
My question is pretty vague :o) - But here is an example : When

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.