Friday, December 12, 2008

How to swap two tables without downtime

You can swap two tables in the same schema without messing up any readers by combining rename table operations into a single statement.

rename my_table to my_table_old, my_table_new to my_table;

I haven't checked this but the statement should use a name lock so that attempts to access either table by other clients will be blocked until the statements complete.

No comments: