Is it possible to create a new id serial column inside a view? I need it to be able to add my view in postgis
I have made a full outer join on two tables
I need a unique PK to load the view in QGIS.
Creating a id serial does not help in this case because it will become redundant once the two tables are joined.
This is my view:
CREATE OR REPLACE VIEW myview AS SELECT table1.id table1.name table2.id table2.street FROM table1 FULL OUTER JOIN table2 ON table1.id = table2.id
I have seen some ROW_NUMBER examples but i dont know how to script it when I am using a join.In PostGIS is it possible to create a View with a unique ID?
a final try before I find another direction to solve my problem. It is a try to use the row_number to create a unique column inside my VIEW. It looks daunting and it does not work.. probably not the best way of solving my problem (Iam not very experienced writing script yet.. but i give it a last try in case it is just a quick fix)
create view testView as (
select
row_number() OVER(ORDER BY (SELECT
table1.id
table1.name
table2.id
table2.street
FROM table1
FULL OUTER JOIN table2
ON table1.id = table2.id) AS OID,
table1.id
table1.name
table2.id
table2.street
FROM table1
FULL OUTER JOIN table2
ON table1.id = table2.id
