MySQL database error. Permanent, random, or time-dependent expressions in the (sub) partition function are not allowed

I tried to make a partition using the timestamp in mysql table. But it returns 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; 
+4
source share
1 answer

Well, the error message is pretty clear. Do not separate values ​​in a time-dependent column. Use a column with a date , datetime or int data type (by evaluating DAYOFYEAR(fld_crtdate) in advance in a separate column) or any other.

+3
source

Source: https://habr.com/ru/post/1500672/


All Articles