更改表中的列名称 [英] Alter the column name in a table
本文介绍了更改表中的列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下查询来更改表格中的列名。
SP_RENAME'Student.StudentId','SID','COLUMN'
用于更改表中列名的任何备用查询。
Hi,
I am using the below query to change the column name in a table.
SP_RENAME 'Student.StudentId', 'SID ', 'COLUMN'
Any alternate query to change the column name in a table.
推荐答案
据我所知:不。
注意:您需要先禁用列上的任何约束并修改它们对于新列也是活跃的。
但是,如果更适合你,可以使用列的新名称再次删除并创建表;)
As far as I know: No.
Note: You need to disable any constraints on the column first and modify them too to be active for the new column.
But, you could drop & create the table again with the new name of the column if that suits you more ;)
您还可以通过SSMS中的对象资源管理器或表设计器更改列的名称。
这是指向的链接微软文档 [ ^ ]关于如何实现这个
当您从原始表中进行选择时,按名称详细说明每列,将其更改为使用Student.StudentId AS SID
。将列名从StudentId更改为SID并没有真正实现多少
You can also change the name of a column via the Object Explorer or Table Designer in SSMS.
Here is the link to the microsoft documentation[^] on how to achieve this
When you are doing a select from your original table detailing each column by name change it to useStudent.StudentId AS SID
instead. Changing a column name from StudentId to SID doesn't really achieve much
这篇关于更改表中的列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文