sql - Add non-existing column to view -
is possible add together serial column existing view if field not exist in source table? want autoincremental id field named oid cannot null.
create or replace view public.osm_polygon select planet_osm_polygon.osm_id::text osm_id, planet_osm_polygon.tags -> 'osm_timestamp'::text osm_timestamp, planet_osm_polygon.tags -> 'name:en'::text name_en, planet_osm_polygon.access, planet_osm_polygon.admin_level, planet_osm_polygon.aerialway, planet_osm_polygon.aeroway, planet_osm_polygon.amenity, planet_osm_polygon.area, planet_osm_polygon.barrier, planet_osm_polygon.bicycle, planet_osm_polygon.brand, planet_osm_polygon.bridge, way planet_osm_polygon.boundary, planet_osm_polygon.building planet_osm_polygon st_isvalid(planet_osm_polygon.way) , planet_osm_polygon.way && st_makeenvelope((-17.5)::double precision, 3.0::double precision, 8.7::double precision, 26.9::double precision, 4326);
so view.
i need add together column contains auto-incremental field long integers or serial cannot null. suggestions?
using row_number ?
create or replace view public.osm_polygon select planet_osm_polygon.osm_id::text osm_id, planet_osm_polygon.tags -> 'osm_timestamp'::text osm_timestamp, planet_osm_polygon.tags -> 'name:en'::text name_en, planet_osm_polygon.access, planet_osm_polygon.admin_level, planet_osm_polygon.aerialway, planet_osm_polygon.aeroway, planet_osm_polygon.amenity, planet_osm_polygon.area, planet_osm_polygon.barrier, planet_osm_polygon.bicycle, planet_osm_polygon.brand, planet_osm_polygon.bridge, way, planet_osm_polygon.boundary, planet_osm_polygon.building, row_number() over() row_num planet_osm_polygon st_isvalid(planet_osm_polygon.way) , planet_osm_polygon.way && st_makeenvelope((-17.5)::double precision, 3.0::double precision, 8.7::double precision, 26.9::double precision, 4326);
sql postgresql view
No comments:
Post a Comment