MySQL 8.0 報錯:Identifier name 'ix_xxx' is is too long
阿新 • • 發佈:2019-01-11
某日在測試庫中新加索引報錯: Identifier name 'ix_orgid_warehouseid_businessType_orderCreateTime_state_ordertype' is too long CREATE INDEX ix_orgid_warehouseid_businessType_orderCreateTime_state_ordertype ON oms_order_2.orders(Org_Id,Warehouse_Id,businessType,orderCreateTime,state,ordertype); 解釋資訊: MySQL的索引名支援最大64個字元,超出則報錯。 SELECT CHARACTER_LENGTH('ix_orgid_warehouseid_businessType_orderCreateTime_state_ordertype') AS NUM; NUM -------- 65 將其中一個s去掉變為64字元則可以執行。 CREATE INDEX ix_orgid_warehouseid_businesType_orderCreateTime_state_ordertype ON oms_order_2.orders(Org_Id,Warehouse_Id,businessType,orderCreateTime,state,ordertype); 注意的地方: MySQL 雖然支援物件名(table、index、view等)最大為64字元,一般建議不超過32字元。 這樣可以方便的相容其他型別的資料庫比如oracle等。