"alter table named"和"rename table"有什么区别? [英] what is the difference between 'alter table rename' and 'rename table'?
问题描述
我正在使用MySQL.这是一个示例,我想将表A重命名为B,所以以下语句之间有什么区别:
alter table A rename to B;
和这个:
rename table A to B;
谁能提供详细的比较?会因引擎不同而异吗?
如 RENAME TABLE
语句来重命名表.参见第13.1.32节"RENAME TABLE
语法" .)专为重命名表授予的任何特权都不会迁移到新名称.必须手动更改它们.
如 RENAME TABLE
语法所述:
RENAME TABLE
与ALTER TABLE
不同,可以重命名一条语句中的多个表:RENAME TABLE old_table1 TO new_table1, old_table2 TO new_table2, old_table3 TO new_table3;
[ deletia ]
RENAME TABLE
不适用于TEMPORARY
表.但是,可以使用ALTER TABLE
重命名临时表. /p>
RENAME TABLE
适用于视图,但不能将视图重命名到其他数据库中.
没有其他区别.
I am using MySQL. Here's an example, I want to rename a table A to B, so what's the difference between following statement:
alter table A rename to B;
and this one:
rename table A to B;
Can anyone give a detail compare between them? Is it vary based on different engine?
As documented under ALTER TABLE
Syntax:
For
ALTER TABLE tbl_name RENAME TO new_tbl_name
without any other options, MySQL simply renames any files that correspond to the tabletbl_name
without making a copy. (You can also use theRENAME TABLE
statement to rename tables. See Section 13.1.32, "RENAME TABLE
Syntax".) Any privileges granted specifically for the renamed table are not migrated to the new name. They must be changed manually.
As documented under RENAME TABLE
Syntax:
RENAME TABLE
, unlikeALTER TABLE
, can rename multiple tables within a single statement:RENAME TABLE old_table1 TO new_table1, old_table2 TO new_table2, old_table3 TO new_table3;
[ deletia ]
RENAME TABLE
does not work forTEMPORARY
tables. However, you can useALTER TABLE
to rename temporary tables.
RENAME TABLE
works for views, except that views cannot be renamed into a different database.
There are no other differences.
这篇关于"alter table named"和"rename table"有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!