SQL 2005 找出谁创建了视图
SQL 是否存储有关谁最初创建视图或谁最后修改视图的任何信息?
Does SQL store any information about who originally created a view, or who last modified it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
现在已经太晚了,但是如果您使用的是 2008,您可以创建一个 审核 将跟踪未来的更改。
编辑:找到了!
这将产生有关数据库中视图的许多有趣的详细信息,包括principal_id 列。 加入 sys.database_principals 上的principal_id 作为用户名!
It's too late now, but if you were using 2008 you could create an audit that will track future changes.
EDIT: found it!
This will produce a number of interesting details about the views in your database, including the column principal_id. Join with sys.database_principals on principal_id for the username!
我不确定是否有办法查看谁创建了视图,但是 sp_help 将为您提供有关视图创建时间的一些信息
sp_help 可以用于任何和所有数据库对象。
I am not sure if there is a way to see who created the view but sp_help will get you some information on when it was created
sp_help works on any and all database objects BTW.
SQL Server 不存储有关谁创建或修改对象的显式信息。 元数据目录中包含有关谁是给定对象的所有者或该对象属于哪个架构的信息:
根据对象类型,principal_id 填充为所有者的数据库主体 ID,或者 schema_id 为使用对象所属架构的 Id 进行填充。 所有模式都有一个所有者,并且可以从元数据目录中检索:
但是请注意,这些只会显示对象的所有者。 所有者不一定是指创建或修改它的用户。 可以在创建期间或创建后使用 ALTER AUTHORIZATION 声明,使得通过所有权进行的身份识别充其量是不可靠的。 此外,sysadmin 角色的所有成员都映射到每个数据库中的同一数据库主体 dbo。
要正确识别创建对象的用户,您应该部署审核方法,但这需要事先部署审核。 如果未部署审计,则可以在事后进行一些取证:
SQL Server does not store explicit information about who created or modified an object. There is information in the metadata catalog about who is the owner of a given object, or to what schema does the object belong to:
Depending on the object type either the principal_id is populated with the database principal ID of the owner, or the schema_id is populated with the Id of the schema to which the object belongs. All schemas have an owner and which can be retrieved from the metadata catalog:
However note that these will only reveal the owner of the object. The owner does not necessarily means the user that created it or modified it. Ownership of objects can be changed during creation or after creation with the ALTER AUTHORIZATION statement, making identification by ownership unreliable at best. Also all members of sysadmin role map to the same database principal, dbo, in every database.
To properly identify the the user that created an object you should deploy auditing methods, but that require prior deployment of the audit. Some forensics can be done after the fact if audit was not deployed: