鉴于这种 :
delimiter //
create procedure setup()
begin
declare d datetime;
set d = rounddate(now());
create table s_time (req_id int not null,
ser_id int not null,
hel_id int not null,
posted int unsigned not null,
completed int unsigned not null default 0
)
partition by range (completed) (partition p0 values less than ( unix_timestamp(d) ),
partition p1 values less than ( unix_timestamp(d + interval 1 day) )
);
end//
I get :
ERROR 1064 (42000) : Constant, random, or timezone-dependent expression in (sub)partitioning function are not allowed
有什么方法可以让它工作,或者我是否必须使用硬编码字符串作为输入。即使用:unix_timestamp('2012-07-07 00:00:00')
为了将解决方案保留在完整的sql中,这就是我发现的。
delimiter //
create procedure setup()
begin
declare d, d2 int;
set d = unix_timestamp();
set d2 = unix_timestamp(now() + interval 1 day);
create table s_time (req_id int not null,
ser_id int not null,
hel_id int not null,
posted int unsigned not null,
completed int unsigned not null default 0
);
SET @stmt = concat('alter table s_time PARTITION BY RANGE (completed) (
partition p0 values less than (', d, '),
partition p1 values less than (', d2, '))');
PREPARE pStmt FROM @stmt;
EXECUTE pStmt;
DEALLOCATE PREPARE pStmt;
end//
delimiter ;
call setup();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)