开发者

xtype vs type column in Sysobjects

Can anyone tell me why Sysobjects table have two c开发者_运维问答olumns xtype and type. Both are of data type char(2) and stores the object type.


I believe type should be used as it is still in the new view. xtype is there for backward compatibility.

NOTE:

It appears that sys.sysobjects will be removed in future versions and you should use sys.objects instead.


You can look at the definition of sysobjects

select OBJECT_DEFINITION(OBJECT_ID('sysobjects')) 
AS [processing-instruction(x)] FOR XML PATH('') 

Which Gives

CREATE VIEW sys.sysobjects AS
 SELECT  
 /*... Snip ...*/
 xtype = type collate database_default,
 /*... Snip ...*/
 type = convert(char(2), case type
  when 'UQ' then 'K' when 'PK' then 'K'
  else type collate database_default end),
 /*... Snip ...*/  
 FROM sys.sysschobjs

So it appears they only differ in whether UQ and PK or shown as K or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜