当前位置: 首页 > news >正文

获取业务库的schema信息导出成数据字典

获取业务库的schema信息导出成数据字典

场景:需要获取业务库的schema信息导出成数据字典,以下为获取oracle与mysql数据库的schema信息语句


--获取oracle库schema信息
selecttt1.owner as t_owner,tt1.table_name,tt1.column_name,tt1.data_type,tt1.data_length,tt1.nullable,tt1.comments,tt1.column_id,tt2.pkcols
from
(selectatc.owner,atc.table_name,atc.column_name,atc.data_type,atc.data_length,atc.nullable,acc.comments,atc.column_idfrom all_tab_columns atcjoin all_col_comments accon atc.table_name=acc.table_nameand atc.owner=acc.ownerand atc.column_name=acc.column_name
) tt1
left join(SELECT OWNER,table_name,LISTAGG(column_name,',') WITHIN group(ORDER BY column_name) AS pkcolsFROM(select a.OWNER,a.table_name,a.column_namefrom all_cons_columns ajoin all_constraints bon a.constraint_name = b.constraint_nameand a.OWNER=b.OWNERand b.constraint_type = 'P') t1GROUP BY OWNER,table_name
)tt2
on tt1.OWNER=tt2.OWNER
and tt1.table_name=tt2.table_name
order by tt1.owner,tt1.table_name, tt1.column_id;--获取mysql库schema信息
selecttt1.table_schema as t_owner,tt1.table_name,tt1.column_name,tt1.data_type,tt1.character_maximum_length,tt1.is_nullable,tt1.column_comment,tt1.ordinal_position,tt2.pkcols
from information_schema.COLUMNS tt1
left join
(selectCONSTRAINT_SCHEMA,table_name,group_concat(column_name order by ordinal_position separator ',') as pkcolsfrom information_schema.key_column_usage twhere constraint_name='PRIMARY'group by CONSTRAINT_SCHEMA,table_name
)tt2
on tt1.table_schema=tt2.CONSTRAINT_SCHEMA
and tt1.table_name=tt2.table_name
order by tt1.table_schema,tt1.table_name, tt1.ordinal_position
http://www.lryc.cn/news/434669.html

相关文章:

  • 力扣: 快乐数
  • 一般位置下的3D齐次旋转矩阵
  • 每日一题——第八十六题
  • 十、组合模式
  • 一分钟了解网络安全风险评估!
  • 【springsecurity】使用PasswordEncoder加密用户密码
  • 从0到1实现线程池(C语言版)
  • Visual studio自动添加头部注释
  • 【C#生态园】提升性能效率:C#异步I/O库详尽比较和应用指南
  • 管理医疗AI炒作的三种方法
  • VMware Workstation Pro Download 个人免费使用
  • DevOps平台搭建过程详解--Gitlab+Jenkins+Docker+Harbor+K8s集群搭建CICD平台
  • Nginx之日志切割,正反代理,HTTPS配置
  • Mysql数据量大,如何拆分Mysql数据库(垂直拆分)
  • 机器人可能会在月球上提供帮助
  • 真实案例分享:零售企业如何避免销售数据的无效分析?
  • ctfshow-文件包含
  • Qt事件处理机制
  • vue axios 如何读取项目下的json文件
  • 燃气涡轮发动机性能仿真程序GSP12.0.4.2使用经验(二):使用GSP建立PG9351FA燃气轮机性能仿真模型
  • 迟滞比较器/施密特触发器
  • LeetCode_sql_day22(1112.每位学生的最高成绩)
  • OFDM信号PARP的CCDF图
  • LeetCode之高频SQL50题
  • echarts多组堆叠柱状图
  • 打造安心宠物乐园:EasyCVR平台赋能猫咖/宠物店的智能视频监控解决方案
  • springboot请求传参常用模板
  • HTML/CSS/JS学习笔记 Day4(HTML--C3 表格)
  • WPF中创建横向的ListView
  • A表和B表公共元素产生链表C