Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991

Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993
Question 23: Which of the following will most likely execute faster? – MySQL Question of the Day

Skip to content

By urs in mysql questions

 

a) alter table tt.sales add column bla1 varchar(200),
         add index bla_idx(bla),
         add column bla2 varchar(200) default ' ';
 
b)  alter table tt.sales add column bla1 varchar(200);
    alter table tt.sales add index bla_idx(bla);
    alter table tt.sales add column bla2 varchar(200) default ' ';
 
c) a and b do exactly the same: they will execute in the same time.

 
[ Tables and Indexes (15%) - Altering Tables ]
 

Tags: , ,

Comment Feed

One Response


  1.  
    Answer:
     
    a
     
    ALTER TABLE will (mostly) create a temporary table with the new structure, fill it and finally rename it. So it is better, to do as much as possible in a single ALTER TABLE command.
     
    Especially with large tables, this can save a lot of time.
     

You must be logged in to post a comment.