Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Database Error: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed

Tags:

mysql

I was tried to make partition by the timestamp in mysql table. But it is returning an error

CREATE TABLE tblemployeepunch (
  fld_id int(11) NOT NULL AUTO_INCREMENT,
  fld_date Varchar(15) DEFAULT NULL,
  fld_rawpunchdate varchar(25) DEFAULT NULL,
  fld_rawpunchtime varchar(25) DEFAULT NULL,
  fld_cardno varchar(50) DEFAULT NULL,
  fld_reasoncard varchar(20) DEFAULT NULL,
  fld_mode varchar(20) DEFAULT NULL,
  fld_punchdatetime varchar(50) DEFAULT NULL,
  fld_crtdate  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY fld_id (fld_id,fld_crtdate),
  KEY in_timesheet (fld_cardno,fld_punchdatetime,fld_mode,fld_rawpunchtime),
  KEY in_emppunch (fld_cardno,fld_rawpunchdate,fld_punchdatetime)
  )
  PARTITION BY HASH(DAYOFYEAR(fld_crtdate))
PARTITIONS 12;
like image 590
sudhakar reddy karukala Avatar asked Sep 05 '13 08:09

sudhakar reddy karukala


1 Answers

Well, the error message is quite clear. Don't partition by values which are in a timezone-dependent column. Use a column which has datatype date, datetime or int (by calculating DAYOFYEAR(fld_crtdate) beforehand in a separate column) or any other.

like image 191
fancyPants Avatar answered Oct 21 '22 17:10

fancyPants