清理数据的通常策略如下:
ALTER TABLE Estimates CHANGE COLUMN CreatedDate CreatedDateString VARCHAr(255);ALTER TABLE Estimates ADD COLUMN CreatedDate DATEUPDATe Estimates SET CreatedDate=STR_TO_DATE(CreatedDateString, '%c/%e/%y')) WHERe CreatedDateString IS NOT NULL AND CreatedDateString != ''
然后,当您确信一切都正确转换后:
ALTER TABLE Estimates DROP COLUMN CreatedDateString
适当
DATE字段的优点是它们具有一致的格式,并且当您在其
INDEX上添加数据时,即使在范围内,数据检索也非常快,例如:
SELECT * FROM Estimates WHERe CreatedDate BETWEEN '2016-01-01' AND '2016-06-30'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)