我正在使用 MySQL。这是一个例子,我想将表 A 重命名为 B,那么以下语句之间有什么区别:
alter table A rename to B;
还有这个:
rename table A to B;
有谁能详细比较一下吗?它是否因不同的引擎而异?
最佳答案
根据 ALTER TABLE
Syntax 记录:
For
ALTER TABLE <em>tbl_name</em> RENAME TO <em>new_tbl_name</em>
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.
根据 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;
[ <strong><em>deletia</em></strong> ]
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.
没有其他区别。
关于mysql - 'alter table rename' 和 'rename table' 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18988797/