經常我們要查詢表的索引,約束,相關性,觸發器的屬性,那麼要知道sysobjects這個表的欄位的意思,那麼不管要查什麼都沒有問題!
Sysobjects:SQL-SERVER的每個資料庫內都有此系統資料表,它存放該資料庫內建立的所有對象,如約束、預設值、日誌、規則、預存程序等,每個對象在表中佔一行。以下是此系統資料表的欄位名稱和相關說明。
Name,id,xtype,uid,status:分別是對象名,對象ID,物件類型,所有者對象的使用者ID,對象狀態。
物件類型(xtype)。可以是下列物件類型中的一種:
Object type. Can be one of the following object types:
AF = Aggregate function (CLR)
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
FS = Assembly (CLR) scalar-function
FT = Assembly (CLR) table-valued function
IF = In-lined table-function
IT = Internal table
P = Stored procedure
PC = Assembly (CLR) stored-procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
SN = Synonym
SQ = Service queue
TA = Assembly (CLR) DML trigger
TF = Table function
TR = SQL DML Trigger
TT = Table type
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure
當xtype='U' and status>0代表是使用者建立的表,對象名就是表名,對象ID就是表的ID值。
用: select * from misa.dbo.sysobjects where xtype='U' and status>0 就可以列出庫misa中所有的使用者建立的表名。
SELECT * FROM SYSOBJECTS WHERE PARENT_OBJ = OBJECT_ID( 'CS') AND XTYPE='TR'
列出表cs的所有屬性,上面是trigger!