Manage QGIS Symbology in PostGIS
QGIS layer symbology can be saved into a PostgreSQL database from which the associated layer resides. Whereas projects are stored in individual project tables in each schema, symbologies are stored centrally in a single table that resides in the public schema. The table is called layer_styles and it stores all symbologies associated with any table within the database. It is a powerful, enterprise-level capability that allows administrators to centralize an organization’s symbologies and all that is saved within a QGIS style file.
QGIS symbologies contain much more than just the symbols. A QGIS symbology also contains definitions for labels, attribute forms, joins, diagrams, actions, and more. The following explains some of the key tasks relating to managing QGIS symbologies with PostgreSQL.
Save Default Symbology
- Load a layer from PostgreSQL
- Open the layer properties and modify the symbology and click Apply.
- On the Symbology tab, click the Style button at the bottom of the dialog box > Save as Default > Datasource Database.
- This action will create a new row in the layer_styles table.

Overwrite Default Symbology
To overwrite the default styles, do the same steps to save a default style, but when asked if you wish to overwrite the matching style, click YES. This will overwrite the default style with your current style.

Save multiple symbologies for a single layer
- Open the layer properties for a layer that currently has a default style.
- Change the symbology as needed.
- On the Symbology tab, click the Style button > Save Style.
- For the parameter “Save style” change the drop-down to “In Database (postgres)” and provide an optional description for the style.
- Click OK.

Load symbologies from PostgreSQL
- Load a layer in the project that has multiple symbologies.
- Open the layer properties > Style button > Load Style.
- The section called “Styles related to the layer” will contain a list of styles that can be applied to the current layer.
- Click on a style and then click the “Load Style” button.

Delete Symbologies
Since symbologies are stored as a row in the layer_styles table, deleting a given symbology requires one to delete the row in that table.
- Open a new project in QGIS.
- Expand the PostgreSQL desired database and the public schema.
- Locate the layer_styles table and load it into the current QGIS project.
- Open the attribute table for layer_styles and delete the rows as you would in any spatial or non-spatial table by toggling editing on, deleting the row, saving edits, and toggling editing off.
Best Practices for Managing Symbologies
- Grant read access to the layer_styles table to all users or else they will not be able to access default symbology (more on this in Lesson 8).
- Only grant write access to the layer_styles table to a select few users who are tasked with managing the enterprise-wide symbology.
- Changing the name of the database should be avoided as it will not only break all QGIS projects but layer symbology links will also break.
How can we help?
Contact us today to schedule a free consultation with a member of our team.