SQL Server xtype的介紹

sysobjects 表 
在數據庫內創建的每個對象(約束、默認值、日誌、規則、存儲過程等)在表中佔一行。只有在 tempdb 內,每個臨時對象纔在該表中佔一行。 
列名 數據類型 描述 
name sysname 對象名。 
Id int 對象標識號。 
xtype char(2) 對象類型。可以是下列對象類型中的一種: 
C = CHECK 約束 
D = 默認值或 DEFAULT 約束 
F = FOREIGN KEY 約束 
L = 日誌 
FN = 標量函數 
IF = 內嵌表函數 
P = 存儲過程 
PK = PRIMARY KEY 約束(類型是 K) 
RF = 複製篩選存儲過程 
S = 系統表 
TF = 表函數 
TR = 觸發器 
U = 用戶表 
UQ = UNIQUE 約束(類型是 K) 
V = 視圖 
X = 擴展存儲過程 

uid smallint 所有者對象的用戶 ID。 
info smallint 保留。僅限內部使用。 
status int 保留。僅限內部使用。 
base_schema_ 
ver int 保留。僅限內部使用。 
replinfo int 保留。供複製使用。 
parent_obj int 父對象的對象標識號(例如,對於觸發器或約束,該標識號爲表 ID)。 
crdate datetime 對象的創建日期。 
ftcatid smallint 爲全文索引註冊的所有用戶表的全文目錄標識符,對於沒有註冊的所有用戶表則爲 0。 
schema_ver int 版本號,該版本號在每次表的架構更改時都增加。 
stats_schema_ 
ver int 保留。僅限內部使用。 
type char(2) 對象類型。可以是下列值之一: 
C = CHECK 約束 
D = 默認值或 DEFAULT 約束 
F = FOREIGN KEY 約束 
FN = 標量函數 
IF = 內嵌表函數 
K = PRIMARY KEY 或 UNIQUE 約束 
L = 日誌 
P = 存儲過程 
R = 規則 
RF = 複製篩選存儲過程 
S = 系統表 
TF = 表函數 
TR = 觸發器 
U = 用戶表 
V = 視圖 
X = 擴展存儲過程 
userstat smallint 保留。 
sysstat smallint 內部狀態信息。 
indexdel smallint 保留。 
refdate datetime 留作以後使用。 
version int 留作以後使用。 
deltrig int 保留。 
instrig int 保留。 
updtrig int 保留。 
seltrig int 保留。 
category int 用於發佈、約束和標識。 
cache smallint 保留。   

可以很方便的用 
select * from sysobjects where xtype='TR' and parent_obj=object_id('表名') 
查出表的信息

syscolumns表內的xtype

查了一下,這些東西都是存於每一個數據庫的syscolumns表裏面得,name就是列名,xtype就是數據類型,但是這個xtype是數字的,下面是數字和數據類型對應的關係;

xtype=34 'image' 
 xtype= 35 'text' 
 xtype=36 'uniqueidentifier' 
 xtype=48 'tinyint' 
 xtype=52 'smallint' 
 xtype=56 'int' 
 xtype=58 'smalldatetime' 
 xtype=59 'real' 
 xtype=60 'money' 
 xtype=61 'datetime' 
 xtype=62 'float' 
 xtype=98 'sql_variant' 
 xtype=99 'ntext' 
 xtype=104 'bit' 
 xtype=106 'decimal' 
 xtype=108 'numeric' 
 xtype=122 'smallmoney' 
 xtype=127 'bigint' 
 xtype=165 'varbinary' 
 xtype=167 'varchar'

 xtype=173 'binary' 
 xtype=175 'char' 
 xtype=189 'timestamp' 
 xtype=231 'nvarchar'

 xtype=239 'nchar' 
 xtype=241 'xml' 
 xtype=231 'sysname'

發佈了79 篇原創文章 · 獲贊 16 · 訪問量 59萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章