SQL Server:我应该在sys表上使用information_schema表吗? [英] SQL Server: should I use information_schema tables over sys tables?
问题描述
在SQL Server中,有两种元数据架构:
In SQL Server there is two schemas for metadata:
- INFORMATION_SCHEMA
- SYS
我听说INFORMATION_SCHEMA
表是基于ANSI标准的.开发时存储过程,在sys
表之上使用INFORMATION_SCHEMA
表是否明智?
I have heard that INFORMATION_SCHEMA
tables are based on ANSI standard. When developing e.g. stored procedures, should it be wise to use INFORMATION_SCHEMA
tables over sys
tables?
推荐答案
在直接查询sys
模式时,我总是会尝试使用Information_schema
视图.
I would always try to use the Information_schema
views over querying the sys
schema directly.
视图符合ISO,因此从理论上讲,您应该能够轻松地在不同的RDBMS之间迁移任何查询.
The Views are ISO compliant so in theory you should be able to easily migrate any queries across different RDBMS.
但是,在某些情况下,我所需的信息只是在视图中不可用.
However, there have been some cases where the information that I need is just not available in a view.
我提供了一些链接,其中包含有关视图和查询SQL Server目录的更多信息.
I've provided some links with further information on the views and querying a SQL Server Catalog.
http://msdn.microsoft.com/en-us/library/ms186778.aspx
http://msdn.microsoft.com/en-us/library/ms189082.aspx
这篇关于SQL Server:我应该在sys表上使用information_schema表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!