-----------------------------------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%';