"alter table named"和"rename table"有什么区别? [英] what is the difference between 'alter table rename' and 'rename table'?

查看:1996
本文介绍了"alter table named"和"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 table tbl_name without making a copy. (You can also use the RENAME 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, unlike ALTER 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 for TEMPORARY tables. However, you can use ALTER 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆