数据库表结构比较SQL

--查询A数据库存在,B数据库不存在的表
select * from user_tables t
where not exists(select 1 from user_tables@dblink69 t1 where t.TABLE_NAME=t1.TABLE_NAME)
order by last_analyzed desc;
--查询A数据库与B数据库表列不一致的表
select DISTINCT table_name from ALL_TAB_COLUMNS t
where not exists(select 1 from ALL_TAB_COLUMNS@dblink69 t1 where t.TABLE_NAME=t1.TABLE_NAME and t.COLUMN_NAME=t1.COLUMN_NAME)
and owner='COSEM'
order by table_name
--查询A数据库与B数据库表列不一致的列
select table_name,COLUMN_NAME from ALL_TAB_COLUMNS t
where not exists(select 1 from ALL_TAB_COLUMNS@dblink69 t1 where t.TABLE_NAME=t1.TABLE_NAME and t.COLUMN_NAME=t1.COLUMN_NAME)
and owner='COSEM'
and table_name='SH_INV_DESC'
order by table_name,COLUMN_NAME

展开阅读全文

没有更多推荐了,返回首页