List:General Discussion« Previous MessageNext Message »
From:Baron Schwartz Date:June 13 2007 6:35pm
Subject:Re: Before I shoot myself in the foot...
View as plain text  
Brent Baisley wrote:
> Yes, that will lock up the table while the change is being made. One 
> technique you can use is to rename the table and create a new to catch 
> the incoming data.
> RENAME TABLE x TO y;CREATE TABLE x LIKE y;
> 
> By putting both commands on 1 line, it will execute almost immediately.

If you create the new table first with a different name, then rename to swap the table 
names, it will be atomic (multi-table renames are atomic).  So this would avoid the 
"almost immediately" above:

create table x like y;
rename table y to z, x to y;

Baron
Thread
Before I shoot myself in the foot...Brian Dunning13 Jun
  • Re: Before I shoot myself in the foot...Baron Schwartz13 Jun
    • Re: Before I shoot myself in the foot...Brent Baisley13 Jun
  • Re: Before I shoot myself in the foot...Brian Dunning13 Jun
    • Re: Before I shoot myself in the foot...Ananda Kumar14 Jun
      • Re: Before I shoot myself in the foot...Baron Schwartz14 Jun
        • Re: Before I shoot myself in the foot...Ananda Kumar14 Jun
  • Re: Before I shoot myself in the foot...Martijn Tonies14 Jun
  • Re: Before I shoot myself in the foot...Martijn Tonies14 Jun
Re: Before I shoot myself in the foot...Baron Schwartz13 Jun