我發出以下命令:修改列長度在MySQL
ALTER TABLE `table_name` MODIFY `column_name` VARCHAR(1022)
在它的VARCHAR(1024)
的那一刻,但我得到這個錯誤:
Error Code: 1265 Data truncated for column mysql
我想這是因爲某些行超過1022個字符。當我將IGNORE
添加到命令中時,命令成功完成,但這些行仍有1024個字符,mysql沒有刪除最後2個字符以使其成爲1022,是否有任何方法強制執行此操作,以確保所有行都以新的列大小?
這是我的表:
CREATE TABLE `e_entity` (
`OID` int(11) NOT NULL AUTO_INCREMENT,
`E_E_OID` int(11) DEFAULT NULL,
`UNIQUE_IDX` int(11) NOT NULL,
`APP_OID` int(11) NOT NULL,
`META_OID` int(11) NOT NULL,
`STORE_DATE` datetime NOT NULL,
`REL_DISPLAY` varchar(1024) NOT NULL,
`SINDEX01` varchar(1024) NOT NULL,
`SINDEX02` varchar(1024) NOT NULL,
`SINDEX03` varchar(1024) NOT NULL,
`SINDEX04` varchar(1024) NOT NULL,
`SINDEX05` varchar(1024) NOT NULL,
`SINDEX06` varchar(1024) NOT NULL,
`SINDEX07` varchar(1024) NOT NULL,
`SINDEX08` varchar(1024) NOT NULL,
`SINDEX09` varchar(1024) NOT NULL,
`SINDEX10` varchar(1024) NOT NULL,
`NINDEX01` double NOT NULL,
`NINDEX02` double NOT NULL,
`NINDEX03` double NOT NULL,
`NINDEX04` double NOT NULL,
`NINDEX05` double NOT NULL,
`NINDEX06` double NOT NULL,
`NINDEX07` double NOT NULL,
`NINDEX08` double NOT NULL,
`NINDEX09` double NOT NULL,
`NINDEX10` double NOT NULL,
`DINDEX01` datetime NOT NULL,
`DINDEX02` datetime NOT NULL,
`DINDEX03` datetime NOT NULL,
`DINDEX04` datetime NOT NULL,
`DINDEX05` datetime NOT NULL,
`DINDEX06` datetime NOT NULL,
`DINDEX07` datetime NOT NULL,
`DINDEX08` datetime NOT NULL,
`DINDEX09` datetime NOT NULL,
`DINDEX10` datetime NOT NULL,
`FREETEXT` mediumtext NOT NULL,
`UID` int(11) DEFAULT NULL,
PRIMARY KEY (`OID`),
KEY `App_Parent` (`META_OID`),
KEY `RelDisplay` (`REL_DISPLAY`),
KEY `sindex01` (`META_OID`,`SINDEX01`(64)),
KEY `sindex02` (`META_OID`,`SINDEX02`(64)),
KEY `sindex03` (`META_OID`,`SINDEX03`(64)),
KEY `sindex04` (`META_OID`,`SINDEX04`(64)),
KEY `sindex05` (`META_OID`,`SINDEX05`(64)),
KEY `sindex06` (`META_OID`,`SINDEX06`(64)),
KEY `sindex07` (`META_OID`,`SINDEX07`(64)),
KEY `sindex08` (`META_OID`,`SINDEX08`(64)),
KEY `sindex09` (`META_OID`,`SINDEX09`(64)),
KEY `sindex10` (`META_OID`,`SINDEX10`(64)),
KEY `nindex01` (`META_OID`,`NINDEX01`),
KEY `nindex02` (`META_OID`,`NINDEX02`),
KEY `nindex03` (`META_OID`,`NINDEX03`),
KEY `nindex04` (`META_OID`,`NINDEX04`),
KEY `nindex05` (`META_OID`,`NINDEX05`),
KEY `dindex01` (`META_OID`,`DINDEX01`),
KEY `dindex02` (`META_OID`,`DINDEX02`),
KEY `dindex03` (`META_OID`,`DINDEX03`),
KEY `dindex04` (`META_OID`,`DINDEX04`),
KEY `dindex05` (`META_OID`,`DINDEX05`),
KEY `nindex06` (`META_OID`,`NINDEX06`),
KEY `nindex07` (`META_OID`,`NINDEX07`),
KEY `nindex08` (`META_OID`,`NINDEX08`),
KEY `nindex09` (`META_OID`,`NINDEX09`),
KEY `nindex10` (`META_OID`,`NINDEX10`),
KEY `dindex06` (`META_OID`,`DINDEX06`),
KEY `dindex07` (`META_OID`,`DINDEX07`),
KEY `dindex08` (`META_OID`,`DINDEX08`),
KEY `dindex09` (`META_OID`,`DINDEX09`),
KEY `dindex10` (`META_OID`,`DINDEX10`),
KEY `E_E_OID` (`E_E_OID`)
) ENGINE=InnoDB AUTO_INCREMENT=469158 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;
您可能會嘗試在更改列之前修改值。 'UDATE'table_name'SET'column_name'= LEFT('column_name',1022)' –