在 MS SQL Server 中隐藏表中的列 [英] hide a column from table in MS SQL Server

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

问题描述

任何人都可以分享从 SQL Server 2012 中的表中隐藏特定列的步骤,因为我不想删除该列

隐藏是指每当我对特定表使用选择查询时,它永远不应该显示该列.

有可能吗?无论任何用户登录和我使用的任何查询,我都需要将列设为隐藏

第三方编辑

基于评论 但问题是每当我在 sql 中打开表时,我不想看到该特定列 我认为问题是:

  • 我如何配置

    解决方案

    迟到的帖子,但我认为值得分享

    在 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

    3rd party edit

    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:

    • How can i configure so that opening a table definition inside sql management studio to only show the columns the connected user has select right to?

    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

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

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