在 SQL Server 2000 中,是否有一个 sysobjects 查询将检索用户视图而不是系统视图?

发布于 2024-07-05 10:44:20 字数 140 浏览 9 评论 0原文

假设存在这样的查询,我将非常感谢您的帮助。

我正在尝试开发一个权限脚本,该脚本将授予对数据库中的用户表和视图的“选择”和“引用”权限。 我希望在这样的集合中的每个元素上执行“grant”命令将使在将新表和视图添加到数据库时更容易保持权限最新。

Assuming such a query exists, I would greatly appreciate the help.

I'm trying to develop a permissions script that will grant "select" and "references" permissions on the user tables and views in a database. My hope is that executing the "grant" commands on each element in such a set will make it easier to keep permissions current when new tables and views are added to the database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

滥情哥ㄟ 2024-07-12 10:44:20
select * from information_schema.tables
WHERE OBJECTPROPERTY(OBJECT_ID(table_name),'IsMSShipped') =0 

将排除 dt_properties 和系统表

添加

where table_type = 'view' 

如果您只想要视图,

select * from information_schema.tables
WHERE OBJECTPROPERTY(OBJECT_ID(table_name),'IsMSShipped') =0 

Will exclude dt_properties and system tables

add

where table_type = 'view' 

if you just want the view

伪装你 2024-07-12 10:44:20
SELECT
    *
FROM
    sysobjects
WHERE
    xtype = 'V' AND
    type = 'V' AND
    category = 0

以下是 xtype 的可能值列表:

  • C = CHECK 约束
  • D = 默认或 DEFAULT 约束
  • F = FOREIGN KEY 约束
  • L = Log
  • P = 存储过程
  • PK = PRIMARY KEY 约束(类型为 K)
  • RF = 复制过滤器存储过程
  • S = 系统表
  • TR = 触发器
  • U = 用户表
  • UQ = UNIQUE 约束(类型为 K)
  • V = 视图
  • X = 扩展存储过程

以下是类型的可能值:

  • C = CHECK 约束
  • D = 默认或 DEFAULT 约束
  • F = 外键约束
  • FN = 标量函数
  • IF = 内联表函数
  • K = PRIMARY KEY 或 UNIQUE 约束
  • L = 日志
  • P = 存储过程
  • R = 规则
  • RF = 复制过滤器存储过程
  • S = 系统表
  • TF = 表函数
  • TR = 触发器
  • U = 用户表
  • V = 视图
  • X = 扩展存储过程

最后,category 字段看起来像是根据不同类型的对象进行分组的。 分析返回结果集后,系统视图的 category = 2,而所有用户视图的 category = 0。希望这会有所帮助。

有关详细信息,请访问 http://msdn.microsoft。 com/en-us/library/aa260447(SQL.80).aspx

SELECT
    *
FROM
    sysobjects
WHERE
    xtype = 'V' AND
    type = 'V' AND
    category = 0

Here is a list of the possible values for xtype:

  • C = CHECK constraint
  • D = Default or DEFAULT constraint
  • F = FOREIGN KEY constraint
  • L = Log
  • P = Stored procedure
  • PK = PRIMARY KEY constraint (type is K)
  • RF = Replication filter stored procedure
  • S = System table
  • TR = Trigger
  • U = User table
  • UQ = UNIQUE constraint (type is K)
  • V = View
  • X = Extended stored procedure

Here are the possible values for type:

  • C = CHECK constraint
  • D = Default or DEFAULT constraint
  • F = FOREIGN KEY constraint
  • FN = Scalar function
  • IF = Inlined table-function
  • K = PRIMARY KEY or UNIQUE constraint
  • L = Log
  • P = Stored procedure
  • R = Rule
  • RF = Replication filter stored procedure
  • S = System table
  • TF = Table function
  • TR = Trigger
  • U = User table
  • V = View
  • X = Extended stored procedure

Finally, the category field looks like it groups based on different types of objects. After analyzing the return resultset, the system views look to have a category = 2, whereas all of the user views have a category = 0. Hope this helps.

For more information, visit http://msdn.microsoft.com/en-us/library/aa260447(SQL.80).aspx

〃温暖了心ぐ 2024-07-12 10:44:20
select * from information_schema.tables
where table_type = 'view'
select * from information_schema.tables
where table_type = 'view'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文