此示例为导出某个表注释的语句 (表名是bbs_bank_log)
SELECT sysobjects name AS 表名 syscolumns name AS 列名 systypes name AS 数据类型 syscolumns length AS 数据长度 CONVERT(char sysproperties [value]) AS 注释FROM sysproperties RIGHT OUTER JOINsysobjects INNER JOINsyscolumns ON sysobjects id = syscolumns id INNER JOINsystypes ON syscolumns xtype = systypes xtype ONsysproperties id = syscolumns id ANDsysproperties *** allid = syscolumns colidWHERE (sysobjects xtype = u ORsysobjects xtype = v ) AND (systypes name <>sysname ) and CONVERT(char sysproperties [value]) <>null 导出注释不为 null 的记录 AND (sysobjects name = bbs_bank_log ) 逐个关联表名 可以用or连接条件ORDER BY 表名
注意事项
上文中的语句是导出某个表的所有注释 如果你需要简单的列出表的所有注释 语句如下
SELECT CONVERT(char [value]) AS Expr FROM sysproperties
lishixinzhi/Article/program/SQL/201311/16240在MySQL数据库中,\x0d\x0a字段或列的注释是用属性comment来添加。\x0d\x0a\x0d\x0a创建新表的脚本中,\x0d\x0a可在字段定义脚本中添加comment属性来添加注释。\x0d\x0a\x0d\x0a示例代码如下:\x0d\x0acreate table test(\x0d\x0aid int not null default 0 comment '用户id'\x0d\x0a)\x0d\x0a\x0d\x0a如果是已经建好的表,\x0d\x0a也可以用修改字段的命令,然后加上comment属性定义,就可以添加上注释了。\x0d\x0a\x0d\x0a示例代码如下:\x0d\x0aalter table test\x0d\x0achange column id id int not null default 0 comment '测试表id\x0d\x0a\x0d\x0a给表的字段或列添加注释已经知道了,\x0d\x0a那么如何来查看已有表的所有字段的注释呢?\x0d\x0a可以用命令:show full columns from table 来查看,\x0d\x0a示例如下:\x0d\x0ashow full columns from test
使用sql语句,查询oracle的表注释等信息方法如下:
一、Oracle 下读取表/字段的备注信息,Oracle 通过COMMENT ON TABLE / COMMENT ON COLUMN 追加表/字段的备注。
COMMENT ON TABLE ,MR_DEPT,IS 。
COMMENT ON COLUMN ,MR_DEPTDEPT_ID,IS。
COMMENT ON COLUMN ,MR_DEPT"PARENT_ID,IS。
COMMENT ON COLUMN ,MR_DEPT"DEPT_NAME,IS 。
COMMENT ON COLUMN ,MR_DEPT"STATUS,IS 。
二、查询表的备注信息
SELECT。
TABLE_NAME。
TABLE_TYPE。
COMMENTS。
FROM。
USER_TAB_COMMENTS。
WHERE-TABLE_NAME -MR_DEPT。
三、查询字段的备注信息
TABLE_NAME。
COLUMN_NAME。
COMMENTS
FROM。
USER_COL_COMMENTS。
WHERE-TABLE_NAME - 'MR_DEPT。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)