Creating queries and views

DB Manager has a SQL window that allows SQL queries to be executed against the database. This section will explain how to use the SQL window to query a table and create a spatial view in SpatiaLite.


Different databases support different SQL commands. SQLite supports much of, but not all, the standard SQL. For a complete listing of supported SQL operations, visit

Creating a SQL query

To create a SQL query, perform the following steps:

  1. Open DB Manager by clicking on DB Manager under Database.
  2. In the Tree panel, navigate to and select the database on which you wish to perform a SQL query.
  3. Navigate to Database | SQL window, or press f2 on your keyboard, to open the SQL window.
  4. Enter ...

Get Mastering QGIS - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.