oracle依据注释查询表信息
-----------------------------------1:建表----------------------------------------
create table EMP
(
EMPNO NUMBER(4) PRIMARY KEY,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
DEPNO NUMBER(4)
);
-----------------------------------2:添加表注释--------------------------------
COMMENT ON TABLE EMP IS '学生信息表';
-----------------------------------3:添加字段注释-----------------------------
COMMENT ON COLUMN EMP.EMPNO IS '学号';
COMMENT ON COLUMN EMP.ENAME IS '姓名';
COMMENT ON COLUMN EMP.JOB IS '邮箱';
COMMENT ON COLUMN EMP.MGR IS '性别';
COMMENT ON COLUMN EMP.HIREDATE IS '入职日期';
COMMENT ON COLUMN EMP.SAL IS '薪资';
COMMENT ON COLUMN EMP.DEPNO IS '部门编号';
-----------------------------------4:依据字段查询表信息--------------------
select * from user_tab_columns where column_name='EMPNO';
-----------------------------------5:依据表名查询字段信息-----------------
select A.COLUMN_NAME,A.DATA_TYPE from user_tab_columns A
where TABLE_NAME='EMP';
-----------------------------------6:获取表--------------------------------------
select table_name from user_tables; ---当前用户拥有的表
-----------------------------------7:依据表注释获取表信息------------------
select * from user_tab_comments where comments like '%xxx%';
-----------------------------------8:依据字段注释获取表/列信息------------
select * from user_col_comments where comments like '%xxx%';
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步