When storing latitude or longitude data in an ANSI SQL compliant database, what datatype would be most appropriate? Should float
be used, or decimal
, or ...?
I'm aware that Oracle, MySql, and SQL Server have added some special datatypes specifically for handling geo data, but I'm interested in how you would store the information in a "plain vanilla" SQL database.
For longitudes use: Decimal(9,6)
, and latitudes use: Decimal(8,6)
If you're not used to precision and scale parameters, here's a format string visual:
###.######
and ##.######