在通过LIST COLUMNS对表进行分区的情况下出现错误

时间:2019-07-02 13:36:49

标签: mysql database-partitioning

我有一个具有以下结构的表:

CREATE TABLE `orders_partition` (
  `Order_Id` bigint(20) NOT NULL,
  `Category_Id` bigint(20) NOT NULL,
  `Order_No` varchar(50) CHARACTER SET latin1 NOT NULL,
  `Student_Id` bigint(20) DEFAULT NULL,
  `Country_Id` bigint(20) NOT NULL,
  `Total_Refers` int(11) NOT NULL,
  `Pages` float(5,1) NOT NULL,
  `Word_count` int(11) NOT NULL,
  `Order_Type_Id` bigint(20) DEFAULT NULL,
  `Reference_Style_Id` int(11) NOT NULL,
  `Payment_Mode_Id` bigint(20) DEFAULT NULL,
  `Payment_Status_Id` bigint(20) DEFAULT NULL,
  `Order_IP` varchar(255) CHARACTER SET latin1 NOT NULL,
  `Order_Amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `Order_Status_Id` bigint(20) DEFAULT NULL,
  `Panic` tinyint(1) NOT NULL DEFAULT '0',
  `Url_Referal_Detail` text CHARACTER SET latin1 NOT NULL,
  `publish_status` int(11) NOT NULL,
  `L_Q_Reason_Id` varchar(255) CHARACTER SET latin1 DEFAULT 'NULL',
  `Transfer_Status` enum('NT','T','A') CHARACTER SET latin1 NOT NULL DEFAULT 'A' COMMENT 'NT=>not transfer,T=>transfer,A=>allowed to transfer',
  `Visibility` enum('E','D') CHARACTER SET latin1 NOT NULL DEFAULT 'E' COMMENT 'E=enabled, D=disabled',
  `Active_Date` datetime NOT NULL,
  `Active_Status` enum('A','DA') CHARACTER SET latin1 NOT NULL DEFAULT 'A' COMMENT 'A=>Active,DA=>Deactive'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `orders_partition`
  ADD PRIMARY KEY (`Order_Id`),
  ADD UNIQUE KEY `Order_Id` (`Order_Id`),
  ADD KEY `Order_Status_Id` (`Order_Status_Id`),
  ADD KEY `Country_Id` (`Country_Id`)

执行以下分区查询

ALTER TABLE orders_partition
PARTITION BY LIST COLUMNS (Active_Status)
(
   PARTITION p01 VALUES IN ('A'),
PARTITION p02 VALUES IN ('DA')
 )

遇到错误

  

1659-此分区类型的字段“ Active_Status”属于不允许的类型

我正打算在我们的mysql表中实现分区(列表列),并且mysql版本是5.7

1 个答案:

答案 0 :(得分:0)

不要尝试对标志进行分区;不可能带来任何好处。

MySQL的 <!-- http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42610 --> <owl:Class rdf:about="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42610"> <rdfs:subClassOf rdf:resource="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42698"/> <obo:IAO_0000115 xml:lang="en">A shortened form of a word or phrase.</obo:IAO_0000115> <oboInOwl:hasDbXref rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://en.wikipedia.org/wiki/Abbreviation</oboInOwl:hasDbXref> <rdfs:label xml:lang="en">abbreviation</rdfs:label> <schema:alternateName xml:lang="en">abbreviations</schema:alternateName> <Property:P1036 rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">411</Property:P1036> </owl:Class> <owl:Axiom> <owl:annotatedSource rdf:resource="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42610"/> <owl:annotatedProperty rdf:resource="https://www.wikidata.org/wiki/Property:P1036"/> <owl:annotatedTarget rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">411</owl:annotatedTarget> <schema:bookEdition rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">20</schema:bookEdition> </owl:Axiom> 有很多限制;您遇到了可以对哪些数据类型进行分区的限制-列表不包含PARTITIONing

如果您不了解这一点,那么下一个错误就是需要在每个唯一键(包括主键)中都包含“分区键”。

与此同时,ENUMUNIQUE(Order_id)是多余的。 PK是(按MySQL的定义)是关键且唯一的。