ORACLE 查询表信息

--oracle库
select * from tabs --查你所在用户下的表 =select * from user_tables
select * from all_tables where owner='VTATEST'; --查某个用户下的所有表
SELECT * FROM USER_TABLES order by TABLE_NAME --查询数据库下所有表名
select column_name,data_type,data_length,DATA_PRECISION ,DATA_SCALE from all_tab_columns where table_name = UPPER('test');
--查询指定表里字段及字段注释
select * from user_tab_columns where Table_Name=UPPER('test'); --获取表字段
select * from user_tab_comments where table_name=UPPER('test') order by TABLE_NAME; --查询所有表及表注释
select * from user_tab_comments where comments like '%日志%'order by TABLE_NAME
select * from user_col_comments --获取字段注释
select COLUMN_NAME,COMMENTS from user_col_comments where TABLE_NAME = UPPER('test'); --查询表字段及字段注释
select TABLE_NAME,COLUMN_NAME,COMMENTS from USER_COL_COMMENTS where TABLE_NAME = UPPER('test');--查表字段注释
-- 字段注释 合成1列 字段为STR
select COLUMN_NAME || ' ' || COMMENTS STR
from USER_COL_COMMENTS
where TABLE_NAME = UPPER('test')
order by COLUMN_NAME;
-- 通过字段注释 查询是否存在想要的字段
select tc.TABLE_NAME, cc.column_name,cc.comments,tc.DATA_TYPE,tc.DATA_LENGTH
from user_tab_columns tc
left join user_col_comments cc on cc.table_name = tc.TABLE_NAME and cc.column_name = tc.COLUMN_NAME
where cc.comments like '%充值%';

posted @ 2021-12-14 14:12  紫陌红尘520  阅读(814)  评论(0编辑  收藏  举报