是否可以向 Microsoft SQL 2000 中的表添加描述/注释?
是否可以向 Microsoft SQL 2000 及更高版本中的表添加类似“元数据”的描述或注释?
您将如何通过 CREATE TABLE 语句来做到这一点?
是否可以向字段添加描述或注释?
如何在 MSSQL 2000 中查询此信息? 2005年?
Is it possible to add a "metadata"-like description or comments to a table in Microsoft SQL 2000 and above?
How would you do this through the CREATE TABLE statement?
Is it possible to add a description or comment to fields?
How do you query this info back in MSSQL 2000? 2005?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用扩展属性。 例如,要将扩展属性添加到 dbo 架构中的表,您可以使用:
您可以更新它们:
您可以像这样读取它们:
或
Use extended properties. For example to add an extended property to a table in the dbo schema you can use:
You can update them:
You can read them like:
or
您当然可以使用上面提到的 SP 来执行此操作,但是,有一种更简单的方法可以执行此操作,并且我相信 MGT Studio 应该是您进行这些更改的首选,除非您尝试使用脚本自动化操作。 操作方法如下:
1- 右键单击表格
2- 单击设计
3- 注释如上所示
为了让您获得完整的答案,这里有一个更简单的脚本来更改它(与上面的答案相比更简单):
You could surely use the SP mentioned above to do it, however, there is an easier way to do it and I believe MGT Studio should be your first choice for making these changes unless you are trying to automate things using a script. Here is how to do it:
1- Right click on the table
2- Click on Design
3- Comment as shown above
Just so you have a complete answer, here is a simpler script to change it (simpler comparing to above answers):
大多数工具和人们使用扩展属性来支持这一点。 SSMS 使用的通用名称是 MS_Description
有几个内置存储过程用于创建这些属性以及读取它们,它们的过程会随着时间的推移而变化,因此 SQL 版本之间会存在兼容性差异。
Most tools and people use the Extended Properties for supporting this. The common name used by SSMS is MS_Description
There are several built in stored procedures for creating these properties as well as reading them, they procs changed over time so there will be compat differences between SQL versions.
不幸的是,这种方法不适用于高负载的生产环境。 操作扩展属性的存储过程在目标表上设置排他锁。 当它们被执行时,整个表是不可读的。
Unfortunately this approach is not applicable to highly loaded production environments. Stored procedures manipulating extended properties set an exclusive lock on the target table. While they are being executed entire table is unreadable.