DEFINE ORIGEM=&1.
DEFINE DEST=&2.

COL DATA_TYPE FORMAT A15
COL OWNER FORMAT A15

SET VERIFY OFF

(
  SELECT '&origem.' ORIGEM, OWNER, TABLE_NAME, COLUMN_ID, COLUMN_NAME, DATA_TYPE||'('||
  DECODE( DATA_PRECISION, NULL, TO_CHAR(DATA_LENGTH), TO_CHAR(NVL(DATA_PRECISION,0)||','||NVL(DATA_SCALE,0)) ) ||')' DATA_TYPE
  FROM DBA_TAB_COLUMNS@&origem. O
  WHERE OWNER = 'SCHEMA'
  AND EXISTS
    (
      SELECT 1 FROM DBA_TABLES@&dest. WHERE OWNER = 'SCHEMA'
      AND O.TABLE_NAME = TABLE_NAME
    )
  MINUS
  SELECT '&origem.', 'SCHEMA', TABLE_NAME, COLUMN_ID, COLUMN_NAME, DATA_TYPE||'('||
  DECODE( DATA_PRECISION, NULL, TO_CHAR(DATA_LENGTH), TO_CHAR(NVL(DATA_PRECISION,0)||','||NVL(DATA_SCALE,0)) ) ||')' DATA_TYPE
  FROM DBA_TAB_COLUMNS@&dest.
  WHERE OWNER = 'SCHEMA'
)
UNION ALL
(
  SELECT '&dest.', OWNER, TABLE_NAME, COLUMN_ID, COLUMN_NAME, DATA_TYPE||'('||
  DECODE( DATA_PRECISION, NULL, TO_CHAR(DATA_LENGTH), TO_CHAR(NVL(DATA_PRECISION,0)||','||NVL(DATA_SCALE,0)) ) ||')' DATA_TYPE
  FROM DBA_TAB_COLUMNS@&dest. O
  WHERE OWNER = 'SCHEMA'
  AND EXISTS
    (
      SELECT 1 FROM DBA_TABLES@&origem. WHERE OWNER = 'SCHEMA'
      AND O.TABLE_NAME = TABLE_NAME
    )
  MINUS
  SELECT '&dest.', 'SCHEMA', TABLE_NAME, COLUMN_ID, COLUMN_NAME, DATA_TYPE||'('||
  DECODE( DATA_PRECISION, NULL, TO_CHAR(DATA_LENGTH), TO_CHAR(NVL(DATA_PRECISION,0)||','||NVL(DATA_SCALE,0)) ) ||')' DATA_TYPE
  FROM DBA_TAB_COLUMNS@&origem.
  WHERE OWNER = 'SCHEMA'
)
ORDER BY OWNER, TABLE_NAME, COLUMN_NAME, 1
/

SET VERIFY ON

UNDEFINE 1
UNDEFINE 2
UNDEFINE ORIGEM
UNDEFINE DEST


hostgator