<div dir="ltr">Hi Gert-Jan,<div><br></div><div>yes - this is done via:</div><div>QGIS....Database menu dropdown --> DB Manager --> select your PostGIS database --> database dropdown, SQL window --> either script your 'view' here, or select the SQL query builder dialogue --> select 'Create View'</div><div><br></div><div>is this what you wanted?</div><div><br></div><div>Tim</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 28, 2022 at 9:16 PM gisnederland via Qgis-user <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Tim and Raymond,<br>
<br>
Perhaps I'd explain a little more:<br>
<br>
The QGis database tool (as Tim suggests) converts my QGis layer <br>
"myLayer" (= a postgis table "myTable" with a QGis filter ("myFilter" <br>
applied to it) to a new postgis *table*<br>
I was hoping to find an (automated!) way to convert the layer to a new <br>
postgis *view*, something like:<br>
   create or replace view "myView"<br>
   as select "myFilter"<br>
   from "myTable"<br>
<br>
<br>
<br>
Kind regards,<br>
<br>
Gert-Jan<br>
<br>
<br>
<br>
tim dunlevie via Qgis-user schreef op 28-04-2022 14:48:<br>
> You can also use the QGIS database tool from the menu...to get to the<br>
> SQL query gui...construct your query through that - add table, add a<br>
> condition (where blah = blah)...then you have the ability to create a<br>
> view in the postgis database.....rather than writing sql query using<br>
> pgadmin etc...<br>
> <br>
> On Thu, 28 Apr 2022, 8:38 pm Raymond Nijssen via Qgis-user,<br>
> <<a href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a>> wrote:<br>
> <br>
>> Hi Gert-Jan,<br>
>> <br>
>> Not sure how exactly you are filtering your data, but to create<br>
>> views<br>
>> you can run these queries on your PostgreSQL database using the tool<br>
>> you<br>
>> like (for example DB-manager in QGIS, or DBeaver or PGAdmin).<br>
>> <br>
>> In case this is an SQL query filter:<br>
>> <br>
>> CREATE VIEW blabla1 AS<br>
>> [your sql select query goes here]<br>
>> <br>
>> In case it's a 'provider object filter' (in the Source tab of your<br>
>> layer<br>
>> properties):<br>
>> <br>
>> CREATE VIEW view_name AS<br>
>> SELECT * FROM table_name WHERE<br>
>> [your filter goes here]<br>
>> <br>
>> Hope this helps,<br>
>> Raymond<br>
>> <br>
>> On 28-04-2022 14:09, gisnederland via Qgis-user wrote:<br>
>>> Hi all,<br>
>>> <br>
>>> I've got a QGis (3.20) project with (amongst others) 15 layers<br>
>> that all<br>
>>> point to 1 postgis table, but all have a different filter applied<br>
>> (in<br>
>>> QGis).<br>
>>> <br>
>>> I'm looking for a convenient way to convert these<br>
>> layers-with-filter to<br>
>>> views in PostGIS, in which the SQL "select"-statement matches the<br>
>> QGis<br>
>>> filter expression.<br>
>>> Any way to do this in QGis, or with other tooling?<br>
>>> <br>
>>> <br>
>>> Kind regards,<br>
>>> <br>
>>> Gert-Jan<br>
>>> _______________________________________________<br>
>>> Qgis-user mailing list<br>
>>> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
>>> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
>>> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
>> _______________________________________________<br>
>> Qgis-user mailing list<br>
>> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
>> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
>> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
> _______________________________________________<br>
> Qgis-user mailing list<br>
> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div>