43人参与 • 2026-03-27 • MsSqlserver
select distinct table_name from dba_tables
where owner ='库名'
and owner not in ('sys','system','outln','xdb','wmsys','ctxsys','mdsys')select distinct table_name from all_tables
where owner ='库名'
and owner not in ('sys','system','outln','xdb','wmsys','ctxsys','mdsys')
select upper(t.table_name),nvl(cc.comments, ''),c.column_name,cc.comments,c.data_type,c.data_length,c.data_precision,c.data_scale
,nullable,case when pk.constraint_type = 'p' then 'y' else 'n' end
from dba_tables t join dba_tab_columns c on t.table_name = c.table_name and t.owner = c.owner
left join dba_col_comments cc on c.owner = cc.owner and c.table_name = cc.table_name and c.column_name = cc.column_name
left join
(select cons.table_name, cons.owner, cols.column_name, cons.constraint_type
from dba_constraints cons
join dba_cons_columns cols on cons.constraint_name = cols.constraint_name
where cons.constraint_type = 'p'
) pk on c.owner = pk.owner and c.table_name = pk.table_name and c.column_name = pk.column_name
where upper(t.table_name) in ( 逗号分隔的表名 ) and t.owner not in ('sys', 'system', 'outln', 'xdb', 'wmsys', 'ctxsys', 'mdsys')
order by t.table_name, c.column_idselect upper(t.table_name),nvl(cc.comments, ''),c.column_name,cc.comments,c.data_type,c.data_length,c.data_precision,c.data_scale
,nullable,case when pk.constraint_type = 'p' then 'y' else 'n' end
from all_tables t join all_tab_columns c on t.table_name = c.table_name and t.owner = c.owner
left join all_col_comments cc on c.owner = cc.owner and c.table_name = cc.table_name and c.column_name = cc.column_name
left join
(select cons.table_name, cons.owner, cols.column_name, cons.constraint_type
from all_constraints cons
join all_cons_columns cols on cons.constraint_name = cols.constraint_name
where cons.constraint_type = 'p'
) pk on c.owner = pk.owner and c.table_name = pk.table_name and c.column_name = pk.column_name
where upper(t.table_name) in ( 逗号分隔的表名 ) and t.owner not in ('sys', 'system', 'outln', 'xdb', 'wmsys', 'ctxsys', 'mdsys')
order by t.table_name, c.column_idselect distinct view_name from all_views
where owner not in ('sys','system','outln','xdb','wmsys','ctxsys','mdsys')
and owner ='库名';select distinct view_name from all_views
where owner not in ('sys','system','outln','xdb','wmsys','ctxsys','mdsys')
and owner ='库名';
select c.table_name as view_name, nvl ( cm.comments, '' ) as cmt, c.column_name, cm.comments, c.data_type, c.data_length, c.data_precision, c.data_scale, c.nullable, 'n' as is_primary_key from dba_tab_columns c left join dba_col_comments cm on c.owner = cm.owner and c.table_name = cm.table_name and c.column_name = cm.column_name where c.owner = '库名' and c.table_name in ( 逗号分隔的表名 ) order by c.table_name,c.column_id
select c.table_name as view_name, nvl ( cm.comments, '' ) as cmt, c.column_name, cm.comments, c.data_type, c.data_length, c.data_precision, c.data_scale, c.nullable, 'n' as is_primary_key from all_tab_columns c left join all_col_comments cm on c.owner = cm.owner and c.table_name = cm.table_name and c.column_name = cm.column_name where c.owner = '库名' and c.table_name in ( 逗号分隔的表名 ) order by c.table_name,c.column_id
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
您想发表意见!!点此发布评论
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论