Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This may be a dumb question, but is there way to run a PostGIS geoprocessing SQL query in QGIS? Specifically, I am thinking of running SQLs such as ST_Union, ST_Split etc etc.

I have tried the following SQL in the QGIS PostGIS Query Editor without any luck, while the query worked in PostGIS.

SELECT covtype, ST_Multi(ST_Union(f.the_geom)) as sGeom
FROM lcc2000_001k AS f
GROUP BY covtype;

SELECT populate_geometry_columns


Thanks in advance...

share|improve this question
I had this problem when I initially started out with QGIS as well. The reason the query does not work within QGIS is because the Query editor treats the area which you can edit as an SQL WHERE clause. Take a look at Mapperz solution. – DMan Jun 29 '12 at 16:09
up vote 5 down vote accepted

You want PgQuery for QGIS

enter image description here

Can be downloaded via Fetch Python Plugins in QGIS and filter for pgquery

share|improve this answer
Thank you, this looks to be a great tool. – Ryan Garnett Jun 29 '12 at 17:04
I have been playing with the plugin and have not been able to make some of the functionality to work, specifically the ability to double-click on a function or a table to add to the query. Does anyone know if there is a limitation while using the plugin with Windows7 64-bit on QGIS v1.8? – Ryan Garnett Jun 29 '12 at 19:14
Running on a Windows 7 64bit with postgis on localhost with QGIS 1.8 no issues. – Mapperz Jun 29 '12 at 19:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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