Oracle数据库查询表名和字段的描述信息SQL脚本

--查询字段类型与名称描述
select a.Table_name,a.column_name,a.data_type,a.data_length,a.data_precision,a.nullable,a.column_id,b.comments
from user_tab_columns a left join user_col_comments b on a.TABLE_NAME=b.table_name and a.COLUMN_NAME=b.column_name 


--查询所有表格的名称
select * from user_tab_comments 

--组成一个大视图
create view v_tabview_struct as 
select a.*,t.column_name,t.comments as column_comments,t.data_type,t.data_length,t.data_precision,t.nullable,t.column_id from user_tab_comments a left join (
select a.Table_name,a.column_name,a.data_type,a.data_length,a.data_precision,a.nullable,a.column_id,b.comments
from user_tab_columns a left join user_col_comments b on a.TABLE_NAME=b.table_name and a.COLUMN_NAME=b.column_name 
) t on a.TABLE_NAME = t.table_name order by a.table_name,t.column_id



你可能感兴趣的:(数据库专题)