Below is an query taken from Metalink which can used to compare the differences(column Names, datatype, datalength) between two tables. However, in Oracle 11g, you may no longer need this query as there is a new package named DBMS_COMPARE which provides more power funtion to facilitate the comparison between tables or schemas.
create table t1 as select * from emp where 1=0;
create table t2 as select * from t1;
alter table t2 drop column ename;
alter table t2 modify job varchar2(10);
column data_type format a10
(select 'IN T1, NOT T2', column_name,data_type,data_length
from user_tab_columns
where table_name = 'T1'
MINUS
select 'IN T1, NOT T2', column_name,data_type,data_length
from user_tab_columns
where table_name = 'T2'
)
UNION ALL
(
select 'IN T2, NOT T1', column_name,data_type,data_length
from user_tab_columns
where table_name = 'T2'
MINUS
select 'IN T2, NOT T1', column_name,data_type,data_length
from user_tab_columns
where table_name = 'T1'
)
/
which gives the following Output
'INT1,NOTT2' COLUMN_NAME DATA_TYPE DATA_LENGTH
------------- ------------------------------ ---------- -----------
IN T1, NOT T2 ENAME VARCHAR2 10
IN T1, NOT T2 JOB VARCHAR2 9
IN T2, NOT T1 JOB VARCHAR2 10
References
Metalink Doc ID: :443557.1

Post a Comment