Point and basic spatial types
A coordinate pair seems simple, and every engine stores one differently: PostgreSQL's built-in POINT is plain 2-D geometry, while MySQL, SQL Server, Oracle and SpatiaLite spatial types carry an SRID.
- Family
- Other types
- Missing in
- SQLite
- Gotchas
- 5 listed
Engine by engine
For a lone (x, y), PostgreSQL has a lightweight POINT type and the others reach for full spatial types; for anything with a map, all five want their spatial machinery and a declared SRID.
| 引擎 | 類型 | 儲存 | 備註 |
|---|---|---|---|
| SQL Server |
geometry / geography Point
|
22 bytes approx | Two spatial types: geometry (planar) and geography (ellipsoidal), built from WKT with STPointFromText or Point(); methods like STDistance differ between them. |
| PostgreSQL |
POINT
|
16 bytes | A plain geometric (x, y) pair of float8 with operators such as <-> (distance) and <@ (contained in a box) but no SRID; real GIS wants PostGIS geometry/geography. |
| MySQL |
POINT
|
25 bytes | 4-byte SRID plus 21-byte WKB. Spatial types date back to 4.1; MySQL 8.0 added the column SRID attribute, geographic SRID math, and rejects SRID mismatches. |
| SQLite |
none (SpatiaLite)
Workaround
|
不適用 | No spatial types built in; the SpatiaLite extension adds geometry columns, R-tree indexes and the ST_ functions, but plain SQLite stores coordinates as two REAL columns. |
| Oracle |
SDO_GEOMETRY
|
~100+ bytes | Oracle Spatial's object type: coordinates plus SDO_SRID, SDO_POINT and index metadata in USER_SDO_GEOM_METADATA; far heavier than a point needs. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- PostgreSQL POINT has no SRID and no geography semantics: point(-73.98, 40.75) <-> point(-0.12, 51.5) returns a distance in degrees. Meters need PostGIS geography or hand-written great-circle SQL.
- SQL Server's geometry and geography types are not interchangeable: geography distances are meters on the ellipsoid, geometry are planar units, and casting between them is a projection, not a cast.
- MySQL 8 enforces SRIDs strictly: mixing SRID 4326 and 0 values in one function call is an error, while 5.7 computed everything as flat Cartesian, so the same query can error or return meters after an upgrade.
- Oracle SDO_GEOMETRY drags metadata with it: you must register dimensions in USER_SDO_GEOM_METADATA before spatial indexes work, a step no other engine requires.
- SQLite has no spatial functions unless SpatiaLite is loaded, which many deployments cannot do; the built-in R*Tree module can still index bounding boxes over two REAL columns.
Common questions
PostgreSQL POINT or PostGIS geometry?
POINT for abstract 2-D coordinates (screen positions, floor plans) where units are yours to define; PostGIS geometry/geography the moment SRIDs, areas, buffers, or real-world maps appear.
How do I store latitude and longitude in MySQL?
A POINT column with SRID 4326 and a SPATIAL index, or two DECIMAL(9,6) columns if you only filter and sort numerically. Avoid 4-byte FLOAT: near 180 degrees it keeps only about 5 decimals, roughly a meter.
Why is Oracle SDO_GEOMETRY so much bigger than a point?
It is an object type carrying SRID, element info and coordinate arrays for shapes beyond points, plus registration metadata. A lone point in SDO_POINT_TYPE still pays the wrapper's overhead.
Related on SQLly
Map a type to the other four engines
The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.