精讲sql server数据库sysObjects表中xtype字段值的含义

经常我们要查询表的索引,约束,相关性,触发器的属性,那么要知道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!

你可能感兴趣的:(Sql,Server,2005,sql,server,数据库,assembly,table,object,function)