如何使用 SQL 查询更改表名? [英] How to change a table name using an SQL query?

查看:33
本文介绍了如何使用 SQL 查询更改表名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用查询语句更改表名?

How can I in change the table name using a query statement?

我使用了以下语法,但在 SQL Server 2005 中找不到 rename 关键字.

I used the following syntax but I couldn't find the rename keyword in SQL server 2005.

Alter table Stu_Table rename to Stu_Table_10

推荐答案

使用 sp_rename:

Use sp_rename:

EXEC sp_rename 'Stu_Table', 'Stu_Table_10'

您可以在 MSDN.

如果您需要包含架构名称,则只能将其包含在第一个参数中(即,这不能用于将表从一个架构移动到另一个架构).因此,例如,这是有效的:

If you need to include a schema name, this can only be included in the first parameter (that is, this cannot be used to move a table from one schema to another). So, for example, this is valid:

EXEC sp_rename 'myschema.Stu_Table', 'Stu_Table_10'

这篇关于如何使用 SQL 查询更改表名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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