0

I have a spatial postgis database named "testdata" having two schema named "afgdata" and "pakdata" with common table names viz. building_a, places, railways, roads, water_a, waterways of different area.

afgdata

pakdata

I am not familiar with both Postgis and FME.

I want to merge both schema in to new schema named "mergedata" within same database. Can anybody help me out to do it with FME or direct in PostgreSQL?

Is it possible to merge both schema and output in new database in public schema?

2

One approach would be to use UNION in PostgreSQL.

For example,

WITH waterways AS (
    SELECT * FROM afg_data.waterways
  UNION ALL
    SELECT * FROM pak_data.waterways
)
SELECT * FROM waterways;
6
  • Thanks Richard, it works. But what for multiple tables?
    – Sachin
    Mar 26 '18 at 8:59
  • The example does have multiple tables. Mar 26 '18 at 9:09
  • Yes in image places, buildings, roads, railways.
    – Sachin
    Mar 26 '18 at 9:11
  • Depending on how many there are and if it's going to be automated, either just write a manual query, or use another query to list the tables in each schema, and use that intermediate result to produce the final query. You might have some issues because your table names are inconsistent (buildings and buildings_a). stackoverflow.com/questions/15644152/… Mar 26 '18 at 20:57
  • I have only following layer : building_a, places, railways, roads, water_a and waterways in both database of different area. Is this possible to merge all layers in a new database or existing database having the same layer?
    – Sachin
    Mar 27 '18 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.