数据库文档数据表、字段信息查询脚本(适用oracle)

数据库文档数据表、字段信息查询脚本(适用oracle)

–适用于ORACLE数据库

00:公共方法(需要先执行)
----00:公共方法(需要先执行)
create or replace function LONG_TO_CHAR(p_table_name in varchar2,p_column_name in varchar2) return varchar2 is
l_column_comments varchar2(32767) default null;
begin
  SELECT dt.DATA_DEFAULT
  INTO  l_column_comments
  FROM all_Tab_Columns dt 
  WHERE 1=1
  and dt.TABLE_NAME = UPPER(p_table_name)
  and dt.COLUMN_NAME = UPPER(p_column_name);
  
  l_column_comments := substr(l_column_comments,0,240);
  return l_column_comments;
exception
  when others then
    return l_column_comments;
end LONG_TO_CHAR;
01:数据字典:传统
-----01:数据字典:传统------------------------------------------------------------------------
SELECT dth.TABLE_NAME,--表名
         dtl.COLUMN_NAME,--列名
         dtlc.comments,--字段描述
         dtl.DATA_TYPE,--字段类型
         dtl.DATA_LENGTH,--字段长度
         dtl.NULLABLE,--是否可为空
         nvl((select 'Y'
          from
           DBA_constraints con,
           DBA_cons_columns col
          where
           con.constraint_name=col.constraint_name
           and con.table_name = dth.TABLE_NAME
           and col.column_name = dtl.COLUMN_NAME
           and con.owner = dth.OWNER
           and con.constraint_type in ('P','R')
           GROUP BY col.column_name),'N') constraints_type,--是否主外键
         LONG_TO_CHAR(dth.TABLE_NAME,dtl.COLUMN_NAME) DATA_DEFAULT--默认值
FROM DBA_TABLES  dth,
         dba_tab_comments dthc,
         Dba_Tab_Columns dtl,
         Dba_Col_Comments dtlc
         WHERE 1=1
         and dth.TABLE_NAME = dthc.table_name
         and dth.OWNER = dthc.owner
         and dthc.table_type = 'TABLE'
         and dth.TABLE_NAME = dtl.TABLE_NAME
         and dth.OWNER = dtl.OWNER
         and dtl.TABLE_NAME = dtlc.table_name
         and dtl.OWNER = dtlc.owner
         and dtl.COLUMN_NAME = dtlc.column_name
         --参数:用户名称(大写)
         and dth.OWNER in ();
02:表清单-
-------02:表清单------------------------------------------------------------------------
         SELECT dth.TABLE_NAME,--表名
                     dthc.comments--表备注
         FROM DBA_TABLES  dth,
         dba_tab_comments dthc
         WHERE 1=1
         and dth.TABLE_NAME = dthc.table_name
         and dth.OWNER = dthc.owner
         and dthc.table_type = 'TABLE'
         --参数:用户名称(大写)
         and dth.OWNER in ();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值