You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enums are an interesting datatype in SQL. Enums can be created with CREATE TYPE in PostgreSQL. Features:
Storage is relatively compact, 4 bytes only. This is less than typical text labels.
Externally they behave mostly like text, making it easy to use.
Enums are sorted by internal encoding, this allows "choosing" order in a sense, for instance by "importance" in a value ("motorway" before "trunk" before "primary",...) instead of text-based ordering. This is useful for map rendering.
Enums can be changed with ALTER TYPE, for instance new values can be added, but they are still not as flexible as free text, of course.
Currently enums can be used with osm2pgsql by creating the enum type before osm2pgsql is run and then using sql_type = 'YOUR_ENUM_TYPE' in the table definition. After that they are used as if they were a text type.
Support in osm2pgsql could help with
Easier to define everything in Lua config instead of having external SQL.
Checking values in osm2pgsql would allow for better error messages instead of failure in the COPY command.
The text was updated successfully, but these errors were encountered:
In practice, you can either have a sortable ordering, or you can alter types. When you use ALTER TYPE you can't pick where in the ordering it goes. You end up having to reimport or update all rows if you want to insert in the middle of your enum.
I wrote a bunch of stuff with ClearTables that made use of ENUMs, but threw it away. The main use I find for ENUMs now is for values which might be something like -1/0/1 such as tunnel/bridge.
Enums are an interesting datatype in SQL. Enums can be created with
CREATE TYPE
in PostgreSQL. Features:ALTER TYPE
, for instance new values can be added, but they are still not as flexible as free text, of course.Currently enums can be used with osm2pgsql by creating the enum type before osm2pgsql is run and then using
sql_type = 'YOUR_ENUM_TYPE'
in the table definition. After that they are used as if they were a text type.Support in osm2pgsql could help with
The text was updated successfully, but these errors were encountered: