更新时间:2023-02-05 09:06:40
迟到的帖子,但我认为值得分享
在 SQLSERVER-2016 之前,选择 *
时没有任何选项可以隐藏表中的几列,但是 SQLSERVER-2016
提出了 HIDDEN
关键字,您现在可以通过该关键字设置对 Select *
隐藏的列,您不想显示这些列,并且只需要您的业务逻辑的某些后台进程.
HIDDEN 属性是可选的,将隐藏这些列来自标准的 SELECT 语句,以便与我们的向后兼容申请和查询.您不能将 HIDDEN 属性应用于现有列
.
您也可以更改现有表,让我们以现有表为例
ALTER TABLE [dbo].[Account] ALTER COLUMN [StartDate] ADD HIDDEN;ALTER TABLE [dbo].[Account] ALTER COLUMN [EndDate] ADD HIDDEN;
您可以在 Temporal table
您可以在下面的Temporal 中找到更多相关信息表
Can anyone please share the steps to hide the particular column from the table in SQL Server 2012 as I don't want to delete that column
By hide I mean that whenever I use the select query against that particular table it should never show me that column.
Is it possible? I need to make the column as hidden irrespective of any user login and whatever query i use
Based on the comment But the problem is whenever i open the table in sql i dont want to see that particular column
i assume that the question is:
The screenshot below shows all columns of the table Employee despite the fact that the login StackoverIntern
has no select rights to the columns SSN, Salary
Late post but I think its worth to share
Earlier to SQLSERVER-2016 there was no any option to hide few columns from table when selecting *
, however SQLSERVER-2016
come up with HIDDEN
keyword by which you can now set columns hidden from Select *
which you don't want to show and want only for some background process of your business logic.
The HIDDEN property is optional and will hide these columns from a standard SELECT statement for backward compatibility with our application and queries. You cannot apply the HIDDEN property to an existing column
.
you can alter existing table as well lets take an example of existing table
ALTER TABLE [dbo].[Account] ALTER COLUMN [StartDate] ADD HIDDEN;
ALTER TABLE [dbo].[Account] ALTER COLUMN [EndDate] ADD HIDDEN;
You can check this concept used more often in Temporal table
you can find more on this in below Temporal Table