List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 15 2001 3:32pm
Subject:Re: Replacing a table safely...
View as plain text  
At 10:06 AM -0500 11/15/01, Anthony R. J. Ball wrote:
>  MySQL 3.23.41 on Solaris
>
>
>   Alright, I have a system where data comes in once... or maybe
>a few times a day. I use this data to recreate a table, and then
>I need to safely and quickly replace the old table. I was thinking
>lock original table, drop it, and then rename the new table, but
>I wasn't sure the lock would stay once the table was dropped. Is
>this the right way to go about it?

Use RENAME TABLE to rename them both in the same statement, then
drop the old one:

RENAME TABLE t TO t_old, t_new TO t;
DROP TABLE t_old;


RENAME TABLE is available as of MySQL 3.23.23.

>
>--
>  ___  __  __    __  _  _  ____    _  _  ____  ____
>/ __)(  )(  )  /__\( \/ )( ___)  ( \( )( ___)(_  _)
>\__ \ )(__)(  /(__)\\  /  )__)    )  (  )__)   )( 
>(___/(______)(__)(__)\/  (____)()(_)\_)(____) (__)
>Do not follow in the footsteps of men of old; seek what they sought.

Thread
Replacing a table safely...Anthony R. J. Ball15 Nov
  • Re: Replacing a table safely...Paul DuBois15 Nov
    • Re: Replacing a table safely...Anthony R. J. Ball15 Nov