系统表master..spt_values的用途是什么?它的值的含义是什么? [英] What is the purpose of system table master..spt_values and what are the meanings of its values?
问题描述
系统表master..spt_values的目的是什么?
为什么提供它,以及如何使用它?
其类型,低,高值的含义是什么?
更新:
Google搜索提供数千种其用途,例如:
- 拆分列使用master..spt_values
- 它包含从0到2047的数字。这是非常有用的,例如如果您需要填充从这个范围100个数字的表格
- 创建虚拟日历
- 以有点不直观和复杂的方式获取对象的描述
枚举SQL Server数据库中的所有索引(Giuseppe Dimauro,devx.com) - SQL Server 2005脚本显示磁盘空间使用情况
-
-
一些帖子警告它的使用,因为它可以在未来版本的SQL Server中删除但已经有代码脚本使用它来说明新的SQL Server 11(Denali)的新功能:
- 使用OFFSET N ROWS FETCH NEXT N ROWS ONLY在SQL Server Denali中方便分页
spt_values
表在SQL Server文档中未提及,但它回到Sybase日期,并且有一些极少的文档在Sybase在线文档中,可以在此评论中总结:
要查看它是如何使用的,请执行sp_helptext并查看
的文本,引用它的系统过程之一。
换句话说,阅读代码并为自己工作。
如果你打开系统存储过程并检查表数据本身,很明显,该表用于将代码转换为可读字符串(除此之外)。或者如上面链接的Sybase文档所述,将内部系统值[...]转换为人类可读的格式
表也是常用的 - 但从来没有在正式文档中 - 通常作为一个方便的源数字列表。但是,如其他地方所述,创建您自己的数字来源是更安全和更多可靠的解决方案比使用未记录的系统表。甚至还有连接请求,以在SQL Server本身中提供正确的文档编号表。 / p>
无论如何,表是完全无记录的,所以没有什么重要的价值,知道任何东西,至少从实际的角度来看:下一个servicepack或升级可能会完全改变。智力好奇是另一回事,当然是: - )
What is the purpose of system table master..spt_values?
Why was it provided and how one should use it?
What are the meanings of its type, low, high values?
Update:
Google search gives thousands of " its uses", for example:
- to split column using master..spt_values
- it contains numbers from 0 to 2047. It is very useful.for example if you need to populate a table with 100 numbers from this range
- for building indexes
- creating virtual calendars
- getting descriptions of used objects in somewhat non-intuitive and complicated way
Enumerate all the indexes in a SQL Server database (Giuseppe Dimauro, devx.com) - "SQL Server 2005 script to display disk space usage"
"It's not worth talking about. This table is a design nightmare of a "super" lookup table"
Some posts warn against its use since it can be removed in future versions of SQL Server but there are already code scripts using it to illustrate new features of new SQL Server 11 (Denali):
- Using OFFSET N ROWS FETCH NEXT N ROWS ONLY In SQL Server Denali for easy paging
The spt_values
table is not mentioned in the the SQL Server documentation but it goes back to the Sybase days and there is some extremely minimal documentation in the Sybase online docs that can be summed up in this comment:
To see how it is used, execute sp_helptext and look at the text for one of the system procedures that references it.
In other words, read the code and work it out for yourself.
If you poke around the system stored procedures and examine the table data itself, it's fairly clear that the table is used to translate codes into readable strings (among other things). Or as the Sybase documentation linked above puts it, "to convert internal system values [...] into human-readable format"
The table is also sometimes used in code snippets in MSDN blogs - but never in formal documentation - usually as a convenient source of a list of numbers. But as discussed elsewhere, creating your own source of numbers is a safer and more reliable solution than using an undocumented system table. There is even a Connect request to provide a 'proper', documented number table in SQL Server itself.
Anyway, the table is entirely undocumented so there is no significant value in knowing anything about it, at least from a practical standpoint: the next servicepack or upgrade might change it completely. Intellectual curiosity is something else, of course :-)
这篇关于系统表master..spt_values的用途是什么?它的值的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!