Skip to content

Instantly share code, notes, and snippets.

@rkolka
Created September 9, 2019 07:41
Show Gist options
  • Save rkolka/a46e66366e16b160af078130fff05560 to your computer and use it in GitHub Desktop.
Save rkolka/a46e66366e16b160af078130fff05560 to your computer and use it in GitHub Desktop.
count geomtypes
SELECT
string_agg(stmt, E' union all\n') as union_stmt
from
(
select
table_schema
, table_name
, column_name
, format($$select %1$L || '.' || %2$L || '.' || %3$L as col, ST_GeometryType(%3$I), count(*) as arv from %1$I.%2$I group by ST_GeometryType(%3$I)$$ , table_schema , table_name , column_name ) as stmt
from
information_schema.columns c
where
udt_name = 'geometry'
) as dummy
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment