Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: compare two tables.

RE: compare two tables.

From: Mark Leith <mark_at_cool-tools.co.uk>
Date: Fri, 24 Aug 2001 02:03:11 -0700
Message-ID: <F001.003769B8.20010824012624@fatcity.com>

srinivas,

The following is a script to compare two schemas. If you don't want to go the whole hog, edit the script - but it may help you in full at some other time.

col table_name         format a30
col column_name        format a30
col medph2_format      format a30

col med_test_format format a30
set feed off
set lines 150
set pages 66
spool match_schema.lst
--

'NUMBER',decode(a.data_scale,0,'NUMBER('||a.data_precision||')',                                                           

'NUMBER('||a.data_precision||','||a.data_scale||')'

                                          ),
                           a.data_type||'('||a.data_length||')'
              )||' '||decode(a.nullable,'N','not null',' ') USERA_format,
        decode(b.data_type,'DATE','DATE',

'NUMBER',decode(b.data_scale,0,'NUMBER('||b.data_precision||')',
                                                          
'NUMBER('||b.data_precision||','||b.data_scale||')'
                                          ),
                           b.data_type||'('||b.data_length||')'
              )||' '||decode(b.nullable,'N','not null',' ') USERB_format
        from all_tab_columns a,
             all_tab_columns b
        where a.owner = 'USERA'
          and b.owner = 'USERB'
   and a.table_name = b.table_name
          and a.column_name = b.column_name
          and (a.data_type <> b.data_type
               or a.data_length <> b.data_length
               or a.data_precision <> b.data_precision
               or a.data_scale <> b.data_scale
               or a.nullable <> b.nullable)
        order by 1, 2

/
--

HTH Mark

-----Original Message-----

Shrinivas (MED, Keane)
Sent: Friday, August 24, 2001 09:20
To: Multiple recipients of list ORACLE-L

Hi lists

while doing export & import, often I need to check whether the target table has any excess columns or does the column have different datatypes/sizes from source table.

as our tables have many columns it has become tedious to check every time.

can anybody post me any sql or pl/sql script that will perform the above task.

the query needs to perform the check on 2 tables. the tables will have same name in different schemas.

but the columns in them may vary or the datatypes/sizes to same columns may vary in source and target.

it has to pick out the differed columns, sizes.

thanx in advance.
srinivas

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Tatireddy, Shrinivas (MED, Keane)   INET: Shrinivas.Tatireddy_at_med.ge.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Mark Leith
  INET: mark_at_cool-tools.co.uk

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Aug 24 2001 - 04:03:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US