什么是“神”?系统表?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
sys.objects
用于数据库中的对象,例如表、存储过程、视图等。我认为您需要以下表格:
编辑
我能找到的最接近的东西有关系统视图的详细信息,请参阅此。它按视图类型将它们分开。例如,深入查看
目录视图
>安全目录视图
将为您提供安全相关视图的视图 例如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:
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.我希望此链接可能有用。您需要的所有视图都位于安全目录视图。另外,您可能需要查询 sys.database_principals 而不是过时的
sysusers
和syslogins
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 obsoletesysusers
andsyslogins
从 sys.sysusers 中选择 *
从 sys.asymp_keys 中选择 *
从 sys.syslogins 选择 *
从 sys.certificates 选择*
SELECT * FROM sys.sysusers
SELECT * FROM sys.asymmetric_keys
SELECT * FROM sys.syslogins
SELECT * FROM sys.certificates