如何在SQL中更改表的列 [英] How to alter the Column of Table in SQL

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

问题描述

亲爱的开发人员,

如何更改Sql表中列的名称.
我想重命名表的列.
我使用下面的夸克,但不起作用.

Dear Developer,

How to alter the Name of Column in Sql Table.
I want to rename the column of the table.
I use the below quary but its not work.

"Alter table table_name change old_column_name  new_column_name type size"


如果有人在Sql数据库中给我正确的查询,这对我来说非常有用.

问候,
Ravi Sharma


Its greatful for me if anybody give me correct Query in Sql Database.

Regards,
Ravi Sharma

推荐答案

运行此脚本:

Run this script:

EXEC sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'



希望对您有所帮助:)



hope it helps :)


http://msdn.microsoft. com/en-us/library/ms188351.aspx [ ^ ]


使用sp_rename.
在此了解更多信息 [ ^ ]或此处 [ ^ ].
Use sp_rename.
Read more about this here[^] or here[^].


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

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