Oracle数据库表结构对比
程序员文章站
2022-05-07 09:06:46
...
用SQL对比数据库表结构
首先登陆数据库T,执行下面语句使T可以连接到数据库C:
link_name:C的连接名
user_name:C的用户名
paw:C的密码
create database link link_name
connect to user_name identified by "paw"
using '127.0.0.1/orcl';
select * from WEB_CERTNO_CHECKDETAIL@JCBWG;
执行下面语句进行表字段对比
select *
from (select t1.TABLE_NAME, t1.COLUMN_NAME, t1.DATA_TYPE
from user_tab_columns t1
where not exists (select 1
from (aaa@qq.com) t2
where t1.TABLE_NAME = t2.table_name
and t1.DATA_TYPE = t2.data_type
and t1.COLUMN_NAME = t2.column_name)) t;