create view fielddesc
as
select o.name as oname, c.name as cname,convert(varchar(30),p.value) as value,p.smallid as psmallid,t.name as tname
from syscolumns c
join systypes t on c.xtype = t.xtype
join sysobjects o on o.id=c.id
left join sysproperties p on p.smallid=c.colid and p.id=o.id
where o.xtype='u'
上面是建立注釋查詢試圖。通過上面的語句可以看到某錶某字段的注釋
建立注釋(n'
user
', n
'dbo
', n
'table
' 為固定的)
--為表新增描述資訊
execute
sp_addextendedproperty n
'ms_description',
'人員資訊表
', n
'user
', n
'dbo
', n
'table
', n'表
', null
, null
--為字段a1新增描述資訊
execute
sp_addextendedproperty n
'ms_description',
'姓名', n
'user
', n
'dbo
', n
'table
', n'表
', n
'column
', n'a1
'--為字段a2新增描述資訊
execute
sp_addextendedproperty n
'ms_description',
'性別', n
'user
', n
'dbo
', n
'table
', n'表
', n
'column
', n'a2
'--更新表中列a1的描述屬性:
exec
sp_updateextendedproperty
'ms_description',
'欄位1',
'user
',dbo,
'table',
'表',
'column
',a1
--刪除表中列a1的描述屬性:
exec
sp_dropextendedproperty
'ms_description',
'user
',dbo,
'table',
'表',
'column
',a1
給資料庫字段新增注釋,並且可以通過sql語句查詢
create view fielddesc asselect o.name asoname,c.name ascname,convert varchar 30 p.value asvalue,p.smallid aspsmallid,t.name astname from syscolumns c ...
給資料庫字段新增注釋,並且可以通過sql語句查詢
create view fielddesc as select o.name as oname,c.name as cname,convert varchar 30 p.value as value,p.smallid as psmallid,t.name as tname from syscolu...
Oracle給表和字段新增注釋
oracle給表和字段新增注釋。建立 學生資訊 資料表。建立 學生資訊 資料表 create table student info stu id int,學號 stu name varchar2 8 姓名 email varchar2 20 郵箱 char 2 性別 age int,年齡 class...