创建表的时候添加 表注释
CREATE TABLE WFY(ID INT identity NOT NULL PRIMARY KEY,
NAME CHAR(255) NOT NULL,
SEX CHAR(255) NOT NULL,
AGE CHAR(255) NOT NULL)
GO
EXEC sp_addextendedproperty 'MS_Description',N'主键 ID','SCHEMA','dbo','TABLE','WFY','COLUMN','ID'
GO
EXEC sp_addextendedproperty 'MS_Description',N'姓名 name','SCHEMA','dbo','TABLE','WFY','COLUMN','NAME'
GO
EXEC sp_addextendedproperty 'MS_Description',N'性别 sex','SCHEMA','dbo','TABLE','WFY','COLUMN','SEX'
GO
EXEC sp_addextendedproperty 'MS_Description',N'年龄 age', 'SCHEMA', 'dbo','TABLE','WFY','COLUMN','AGE'
GO
常用的注释语句
为表添加描述信息
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'
更新表中列a1的描述属性:
EXEC sp_updateextendedproperty 'MS_Description','字段1','user',dbo,'table','表','column',a1
删除表中列a1的描述属性:
EXEC sp_dropextendedproperty 'MS_Description','user',dbo,'table','表','column',a1
查看注释:
select * from sys.extended_properties where major_id=OBJECT_ID('WFY')
表
WFY
查看注释如下
1 OBJECT_OR_COLUMN 949578421 1 MS_Description 主键 ID
1 OBJECT_OR_COLUMN 949578421 2 MS_Description 姓名 name
1 OBJECT_OR_COLUMN 949578421 3 MS_Description 性别 sex
1 OBJECT_OR_COLUMN 949578421 4 MS_Description 年龄 age
下面的文章是很写的很深, 有时间好好看看