Some databases support literals of the various GEO type, for example in Postgres, you can do:
SELECT POINT '1,1';
And in Postgres it enforces the sub-type at the column level:
SELECT POINT '1,1' UNION ALL SELECT LINE '0,0,1,1';
ERROR: UNION could not convert type line to point
However, some databases allow using various GEO types in the same column (such as BigQuery, as one example).
- Is it possible to use the
GEO|GEOMETRY|GEOGRAPHYkeyword itself for literal creation, for example something likeSELECT GEO '1,1' FROM tbl? - Is it possible to have a
GEOcolumn that supports any sub-type within it?
CodePudding user response:
The following code seems to do the job.
Having said that, the fact that we can do something doesn't necessarily mean we should do it.
A similar post states:
"Client applications usually deny the work with a single generic geometry type column as well as multiple geometry columns in one table!"
select 'POINT(1 1)'::geography(geometry)
union all select 'LINESTRING(0 0,1 1)'::geography(geometry)
| geography |
|---|
| 0101000020E6100000000000000000F03F000000000000F03F |
| 0102000020E61000000200000000000000000000000000000000000000000000000000F03F000000000000F03F |
