To rotate log tables to keep a set of daily tables covering the last week : RENAME « Command MySQL « SQL / MySQL






To rotate log tables to keep a set of daily tables covering the last week

      

CREATE TABLE log_temp ();

DROP TABLE IF exists log_7;
RENAME TABLE log_6 TO log_7,
log_5 TO log_6,
log_4 TO log_5,
log_3 TO log_4,
log_2 TO log_3,
log_1 TO log_2,
log TO log_1,
log_tmp TO log;

   
    
    
    
    
    
  








Related examples in the same category

1.Rename a table is by using the RENAME TABLE statement
2.RENAME TABLE can perform multiple table renaming operations in a single statement.
3.Renaming a Table
4.RENAME TABLE allows you to rename multiple tables, which allows you to do things such as swap the names of two tables in a single statement
5.Rename a table
6.Rename two tables