What is the ideal data type to use when storing latitude / longitude in a MySQL database?

前端 未结 21 2934
梦如初夏
梦如初夏 2020-11-22 09:40

Bearing in mind that I\'ll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database?

21条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 10:13

    Use DECIMAL(8,6) for latitude (90 to -90 degrees) and DECIMAL(9,6) for longitude (180 to -180 degrees). 6 decimal places is fine for most applications. Both should be "signed" to allow for negative values.

提交回复
热议问题