I want to store a value of lng and lat in database but I am little confused that which data type I should use to store and how much max and min length is required for storing lng and lat values.
Asked
Active
Viewed 4,899 times
1 Answers
2
This question has been discussed before, but notably absent from that discussion is any reference to MySQL's GIS data types. It's possible that POINT (or one of the other geometry data types) would do an excellent job here as well.
The previous discussion concluded that using DECIMAL(10, 8) for latitude and DECIMAL(11, 8) for longitude would be appropriate.

Isaac Bennetch
- 11,830
- 2
- 32
- 43
-
1That precision would give about 1mm resolution. This is excessive for most uses. – Bill Karwin Apr 14 '18 at 17:58
-
@BillKarwin Which data type would, POINT? I'm still a fan of using the native data types designed for a particular use, even if the resolution is better than needed, that way we can let MySQL handle any math involved. Aside from the wasted storage overhead, is there any other reason not to use the GIS data type here? – Isaac Bennetch Apr 14 '18 at 18:03
-
I'd want to know how the app queries the lat/long data. For example, it's not clear how JDBC would map POINT into java types. Could be easier to use DECIMAL. – Bill Karwin Apr 14 '18 at 18:09
-
Also MySQL didn't support POINT in InnoDB until version 5.6, and didn't support spatial indexes on GIS types until version 5.7. If you're stuck using an old version, I'd prefer to use DECIMAL than to use MyISAM tables. – Bill Karwin Apr 14 '18 at 18:11
-
I added more choices [_here_](https://stackoverflow.com/a/50126941/1766831) – Rick James May 02 '18 at 03:58