List:General Discussion« Previous MessageNext Message »
From:Matt Neimeyer Date:September 4 2009 7:53pm
Subject:ALTER TABLE order / optimization
View as plain text  
Given table: CREATE TABLE testtab (d_col CHAR(4));

Question 1: It appears that there is no "harm" in just appending
directives onto the alter table command even if the order doesn't make
sense. It appears the parser figures it out... For example...

   ALTER TABLE testtab ADD COLUMN c_col char(4) FIRST,
      ADD COLUMN b_col char(4) FIRST,
      ADD COLUMN a_col char(4) FIRST;

...does end up with a_col then b_col then c_col then d_col... but does
it matter and I doing something wrong?

Question 2: Is that any more efficient than doing...

   ALTER TABLE testtab ADD COLUMN c_col char(4) FIRST;
   ALTER TABLE testtab ADD COLUMN b_col char(4) FIRST;
   ALTER TABLE testtab ADD COLUMN a_col char(4) FIRST;

If it's NOT more efficient then I won't bother rewriting this one app
which runs slowly to join them up because it certain is easier to read
and debug with each modification on its own line.

Thanks!

Matt
Thread
ALTER TABLE order / optimizationMatt Neimeyer4 Sep
  • RE: ALTER TABLE order / optimizationRolando Edwards4 Sep