Compare User Objects: resulting "alter table..." not optimal

Bernhard S

Member³
When comparing tables where the target side is missing some columns with default values compared to source , the result will be single DMLs like:

SQL:
alter table [TABLE] add a_col1 CHAR(1) default ' ';
alter table [TABLE] add a_col2 CHAR(1) default ' ';
alter table [TABLE] add a_col3 CHAR(1) default ' ';

This requires 3 table scans that can take very long, when you have a huge table. It's much better combining that to one alter table of the form:

SQL:
alter table [TABLE] add
( a_col1 CHAR(1) default ' ',
  a_col2 CHAR(1) default ' ',
  a_col3 CHAR(1) default ' '  );

This will do the job in one table scan.
 
Back
Top