最近有个需要,比对下goldengate 源库 目标库 一些表 表结构 是否一致。当然思路多多,网上搜索下,见到这个链接,觉得写得不错,转载记录下,感谢原作者
https://dataedo.com/kb/query/oracle/compare-tables-and-columns-in-two-schemas
Compare tables and columns in two schemas in Oracle database
Query
select nvl(s1.table_name, s2.table_name) as table_name, nvl(s1.column_name, s2.column_name) as column_name, s1.column_name as schema_1, s2.column_name as schema_2 from ( select table_name, column_name from sys.all_tab_cols where owner = 'schema_1' -- put schema name to compare here ) s1 full join ( select table_name, column_name from sys.all_tab_cols where owner = 'schema_2' -- put schema name to compare here ) s2 on s2.table_name = s1.table_name and s2.column_name = s1.column_name where s1.column_name is null or s2.column_name is null order by table_name, column_name;
复制
Columns
- table_name - name of the table with schema
- column_name - name of column
- schema_1 - if column exists in a table in schema 1 then column contains its name (repeats it from column column)
- schema_2 - if column exists in a table in schema 2 then column contains its name (repeats it from column column)
Rows
- One row represents one distinct name of column in specific table.
- Scope of rows: all distinct columns in that exist only in one of the compared databases.
- Ordered by table and column name
Sample results
文章转载自aknight,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【专家观点】罗敏:从理论到真实SQL,感受DeepSeek如何做性能优化
墨天轮编辑部
1242次阅读
2025-03-06 16:45:38
SQL优化 - explain查看SQL执行计划(一)
金同学
378次阅读
2025-03-13 16:04:22
SQLE 4.0 正式版发布,新增 SQL 重写、SQL 性能追踪、语法知识图谱等功能
爱可生开源社区
345次阅读
2025-03-07 10:30:00
同一条SQL开发环境比生产环境执行速度快案例分享
董小姐
136次阅读
2025-03-20 06:50:49
宝藏PEV,助力你成为SQL优化高手
xiongcc
102次阅读
2025-03-09 23:34:23
MySQL 内存那点事你还不会--PS分析+自动历史SQL分析(2)
AustinDatabases
58次阅读
2025-03-07 10:29:21
同事总写烂SQL,于是我出手了...
IT邦德
50次阅读
2025-03-18 06:40:47
让AI读懂Oracle!使用OCI A10微调大模型生成融合查询SQL
甲骨文云技术
44次阅读
2025-03-19 11:21:10
让DeepSeek来玩玩SQL优化怎么样?
白鳝的洞穴
40次阅读
2025-03-05 11:08:29
金点分享 | 租户→组件→SQL,GoldenDB数据库运维架构全景解读
GoldenDB分布式数据库
35次阅读
2025-03-06 09:27:10