Home > database >  According to the character about mysql field problem of the partition on a monthly basis
According to the character about mysql field problem of the partition on a monthly basis

Time:09-17

Hello everyone, I have a water table, the table is the date of char (8), I want to use this field (trandate) monthly partitions, as follows:
The CREATE TABLE ` accounting ` (
Id INT the NOT NULL AUTO_INCREMENT,
` trandate ` char (8) the NOT NULL DEFAULT ',
` uid ` varchar (20) NOT NULL DEFAULT ',
` terminal ` varchar (20) DEFAULT NULL,
` client_ip ` varchar (16) NOT NULL DEFAULT ',
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

PARTITION BY RANGE (to_days (trandate)) (
PARTITION p201409 VALUES LESS THAN (to_days (' 2014-10-01 ')),
PARTITION p201410 VALUES LESS THAN (to_days (' 2014-11-01 ')),
PARTITION p201411 VALUES LESS THAN (to_days (' 2014-12-01 '));


But this statement has been built the table failed, don't know why, please help each master, thank you!

CodePudding user response:

I there is no MYSQL environment, so can't execute your script,
Can remove the all to_days function try,

CodePudding user response:

Two places error
1
Id INT the NOT NULL AUTO_INCREMENT,
A primary key defined with primary key
Correct term
Id INT the NOT NULL AUTO_INCREMENT primary key ,

the second sentence

` client_ip ` varchar (16) NOT NULL DEFAULT ',

This more than a ", "number
  • Related