sql系统表学习笔记

1.首先见两个表test1,test2

2.目标:先查询一下test1表格和字段的注释


select  a.value,a.*,'---------',o.*
from sysproperties a--sysproperties.value存储了表格和字段的说明
inner join sysobjects o on a.id=o.id and o.name='test1' and o.xtype='U'--id表示这个对象的编号,'U'表示这个对象的是用户表

 

查询结果如下: 可以看到value中不但查出了表格的注释还查询出了字段的注释而且id是一样的,说明字段和表共用一个编号,那么如何区别是表格的注释还是字段的注释呢?,乖乖,原来type字段等于3表示是表格的注释,4表示是字段的注释,我们已经把sysproperties和sysobjects全部的字段都查询出来了,但是却看不到字段的名字,查询字段对应注释就成为了下一个目标

 

laolaowhn

 

value

id

smallid

type

name

value

Expr2

name

id

xtype

uid

info

status

base_schema_ver

replinfo

parent_obj

crdate

ftcatid

schema_ver

stats_schema_ver

type

userstat

sysstat

indexdel

refdate

version

deltrig

instrig

updtrig

seltrig

category

cache

test1 表注释

517576882

0

3

MS_Description

test1 表注释

---------

test1

517576882

U

1

27

1610615063

96

0

0

2009-9-29 16:07

0

96

0

U

1

8307

0

2009-9-29 16:07

0

0

0

0

0

16904

0

ID 注释

517576882

1

4

MS_Description

ID 注释

---------

test1

517576882

U

1

27

1610615063

96

0

0

2009-9-29 16:07

0

96

0

U

1

8307

0

2009-9-29 16:07

0

0

0

0

0

16904

0

 3.目标查询字段对应的注释:


  select  c.name,a.value, a.*,'________',o.*,'________',c.*
  from   SysProperties   a      --sysproperties。value存储了表格和字段的说明
        inner   join   sysobjects  o on a.id=o.id--存储了全部对象的编号名称等信息
     inner    join   syscolumns   c   on   a.id=c.id   and   a.smallid=c.colid  --id表示这个对象的编号,colid表示列的编号,说明c.id还是存储了表格的编号
  where  o.name   =   'test1' 

 

 

查询结果如下:可以看到 a.smallid=c.colid把表的注释过滤掉了,


name

value

id

smallid

type

name

value

Expr3

name

id

xtype

uid

info

status

base_schema_ver

replinfo

parent_obj

crdate

ftcatid

schema_ver

stats_schema_ver

type

userstat

sysstat

indexdel

refdate

version

deltrig

instrig

updtrig

seltrig

category

cache

Expr4

name

id

xtype

typestat

xusertype

length

xprec

xscale

colid

xoffset

bitpos

reserved

colstat

cdefault

domain

number

colorder

autoval

offset

collationid

language

status

type

usertype

printfmt

prec

scale

iscomputed

isoutparamisnullable collation tdscollation

ID

ID 注释

517576882

1

4

MS_Description

ID 注释

________

test1

517576882

U

1

27

1610615063

96

0

0

2009-9-29 16:07

0

96

0

U

1

8307

0

2009-9-29 16:07

0

0

0

0

0

16904

0

________

ID

517576882

56

1

56

4

10

0

1

4

0

0

0

0

0

0

1

null

2

 

0

0

56

7

 

10

0

0

00   null

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值