如何使用sql语句,查询oracle的表注释等信息?
selectcommentsfromUSER_COL_COMMENTSwheretable_name='student'andcolumn_name='stunum'...
select comments
from USER_COL_COMMENTS
where table_name= 'student'
and column_name= 'stunum' 展开
from USER_COL_COMMENTS
where table_name= 'student'
and column_name= 'stunum' 展开
5个回答
展开全部
Oracle 下读取表/字段的备注信息
Oracle 通过COMMENT ON TABLE / COMMENT ON COLUMN 追加表/字段的备注。
CREATE TABLE "MR_DEPT" (
"DEPT_ID" NUMBER NOT NULL ,
"PARENT_ID" NUMBER,
"DEPT_NAME" CHAR(20) NOT NULL ,
"STATUS" NUMBER DEFAULT 1 NOT NULL ,
PRIMARY KEY ("DEPT_ID")
);
COMMENT ON TABLE "MR_DEPT" IS '部门表';
COMMENT ON COLUMN "MR_DEPT"."DEPT_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;
查询字段的备注信息
SELECT
TABLE_NAME,
COLUMN_NAME,
COMMENTS
FROM
USER_COL_COMMENTS
WHERE
TABLE_NAME = 'MR_DEPT;
Oracle 通过COMMENT ON TABLE / COMMENT ON COLUMN 追加表/字段的备注。
CREATE TABLE "MR_DEPT" (
"DEPT_ID" NUMBER NOT NULL ,
"PARENT_ID" NUMBER,
"DEPT_NAME" CHAR(20) NOT NULL ,
"STATUS" NUMBER DEFAULT 1 NOT NULL ,
PRIMARY KEY ("DEPT_ID")
);
COMMENT ON TABLE "MR_DEPT" IS '部门表';
COMMENT ON COLUMN "MR_DEPT"."DEPT_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;
查询字段的备注信息
SELECT
TABLE_NAME,
COLUMN_NAME,
COMMENTS
FROM
USER_COL_COMMENTS
WHERE
TABLE_NAME = 'MR_DEPT;
参考资料: http://hi.baidu.com/wangzhiqing999/blog/item/6e081531bbef0e0790ef39dc.html
展开全部
看看了网上的好多的sql查询语句,但是感觉那些都很简单,有谁能给我些高级这是我做过的几个SQL面试题,我写好了表并添加了测试数据,有兴趣的话试一
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT
a.table_name,
a.column_name,
a.data_type,
CASE WHEN a.data_precision is null THEN a.data_length ||'' else a.data_precision||','||a.data_scale END data_precision_scale,
a.column_id,b.comments
FROM all_tab_columns a,all_col_comments b
WHERE a.owner=b.owner
AND a.table_name=b.table_name
AND a.column_name=b.column_name
AND lower(a.table_name) = ''student'
a.table_name,
a.column_name,
a.data_type,
CASE WHEN a.data_precision is null THEN a.data_length ||'' else a.data_precision||','||a.data_scale END data_precision_scale,
a.column_id,b.comments
FROM all_tab_columns a,all_col_comments b
WHERE a.owner=b.owner
AND a.table_name=b.table_name
AND a.column_name=b.column_name
AND lower(a.table_name) = ''student'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你就直接执行这个即可
select * from user_tab_comments;
select * from user_tab_comments;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
USER_TAB_COMMENTS
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |