用于创建和删除分区的mysql事件

时间:2016-09-30 06:04:22

标签: mysql

我不知道如何解决这个错误。请帮帮我。

[[root@xs32v8-brt-mysql01 ~]# cat e5.sql | mysql -vvvv tmp

CREATE EVENT `Rotate_PerformanceData_Partitions`
    ON SCHEDULE 
        EVERY 1 DAY
    DO 
        BEGIN
            DECLARE Old_Partition VARCHAR(45);
            DECLARE New_Partition VARCHAR(45);  
            DECLARE New_Partition_Value VARCHAR(45);    

        SELECT DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 7 MONTH), 'pn%Y%c') INTO Old_Partition;
        SELECT DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), 'pn%Y%c') INTO New_Partition;
        SELECT UNIX_TIMESTAMP(DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00')) INTO New_Partition_Value;
        ALTER TABLE PerformanceData DROP PARTITION Old_Partition;
        ALTER TABLE PerformanceData ADD PARTITION (PARTITION New_Partition VALUES LESS THAN(New_Partition_Value));
        ALTER TABLE PerformanceDataLI DROP PARTITION Old_Partition;
        ALTER TABLE PerformanceDataLI ADD PARTITION (PARTITION New_Partition VALUES LESS THAN(New_Partition_Value));
   END
  

第2行的ERROR 1064(42000):常数,随机或时区依赖   '()分区函数中的表达式不允许在'))附近;             ALTER TABLE PerformanceDataLI DROP PARTITION Old_Partition;                 '第14行再见[root @ xs32v8-brt-mysql01~]#

0 个答案:

没有答案