In what situation will this succeed:
ALTER TABLE t1 RENAME t2;
but this fail:
RENAME TABLE t1 TO t2;
?
Highlight the white text below for the answer:
When t1 is a temporary table.
Wow… I wonder why that is, I can’t think of any good reason…
In what situation will this succeed:
ALTER TABLE t1 RENAME t2;
but this fail:
RENAME TABLE t1 TO t2;
?
Highlight the white text below for the answer:
When t1 is a temporary table.
Wow… I wonder why that is, I can’t think of any good reason…
Hi Stewart!
Also when you have a non-temporary table and you are under LOCK TABLES.
You cannot use RENAME to rename a TEMPORARY table. However, you can use ALTER TABLE instead:
mysql> ALTER TABLE orig_name RENAME new_name;
http://dev.mysql.com/doc/refman/5.1/en/rename-table.html
For the reasons, ask the devs. But it’s documented. ;-)
Oh it’s well documented, it’s just weird :)