什么是“神”?系统表?

发布于 2024-11-16 11:19:11 字数 447 浏览 3 评论 0原文

IF  EXISTS (SELECT * FROM sys.all_objects WHERE name = N'SOMELOGIN')
DROP USER [SOMELOGIN]
GO

不起作用,因为 USER SOMELOGIN 不在 sys.all_objects 中。

是否有一个全局“上帝”表我可以查看以查看是否存在某些内容。 (即,当它不存在时删除它不会引发错误)

或者是否有在线资源可以查找某些类型的对象所在的位置?

我需要删除以下

  • USER
  • ASYMMETRIC KEY
  • LOGIN
  • CERTIFICATE
IF  EXISTS (SELECT * FROM sys.all_objects WHERE name = N'SOMELOGIN')
DROP USER [SOMELOGIN]
GO

Does not work because USER SOMELOGIN does not live in sys.all_objects.

Is there a global "god" table I can look in to see if something exists. (i.e. dropping it when it doesn't exist doesn't throw an error)

Alternatively is there an online resource for finding out where certain types of objects live?

I need to drop the following

  • USER
  • ASYMMETRIC KEY
  • LOGIN
  • CERTIFICATE

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

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

发布评论

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

评论(3

抚你发端 2024-11-23 11:19:11

sys.objects 用于数据库中的对象,例如表、存储过程、视图等。

我认为您需要以下表格:

SELECT * FROM sys.sysusers
WHERE [name] = 'someUser'

SELECT * FROM sys.asymmetric_keys
WHERE [name] = 'someKey'

SELECT * FROM sys.certificates
WHERE [name] = 'someCertificate'

SELECT * FROM sys.syslogins
WHERE [name] = 'someLogin'

编辑

我能找到的最接近的东西有关系统视图的详细信息,请参阅。它按视图类型将它们分开。例如,深入查看目录视图 > 安全目录视图将为您提供安全相关视图的视图 例如 sys.ametry_keys

我不知道有什么可以为您提供 Logins > sys.syslogins 映射类型。

sys.objects is used for objects in a database, such as tables, stored procedures, views etc.

I think you need the following tables:

SELECT * FROM sys.sysusers
WHERE [name] = 'someUser'

SELECT * FROM sys.asymmetric_keys
WHERE [name] = 'someKey'

SELECT * FROM sys.certificates
WHERE [name] = 'someCertificate'

SELECT * FROM sys.syslogins
WHERE [name] = 'someLogin'

EDIT

The nearest thing I can find for detailing the system views is this. It splits them out by type of view. For instance, drilling down to Catalog Views > Security Catalog Views will give you the views for security related views e.g. sys.asymmetric_keys

I'm not aware of anything that will give you a Logins > sys.syslogins type of mapping.

怎会甘心 2024-11-23 11:19:11

I hope this link might be useful. All views you need are under Security Catalog Views. Also, you probably need to query sys.database_principals instead of obsolete sysusers and syslogins

徒留西风 2024-11-23 11:19:11
  • 用户 => 从 sys.sysusers 中选择 *
  • 不对称键 => 从 sys.asymp_keys 中选择 *
  • 登录 => 从 sys.syslogins 选择 *
  • 证书 => 从 sys.certificates 选择*
  • USER => SELECT * FROM sys.sysusers
  • ASYMMETRIC KEY => SELECT * FROM sys.asymmetric_keys
  • LOGIN => SELECT * FROM sys.syslogins
  • CERTIFICATE => SELECT * FROM sys.certificates
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文