Outdated version of the documentation. Find the latest one here.

.

Extension DB Manager

The DB Manager Plugin is officially part of the QGIS core and is intended to replace the SPIT Plugin and, additionally, to integrate all other database formats supported by QGIS in one user interface. The icon_dbmanager DB Manager Plugin provides several features. You can drag layers from the QGIS Browser into the DB Manager, and it will import your layer into your spatial database. You can drag and drop tables between spatial databases and they will get imported. .. _figure_db_manager:

Figure DB Manager 1:

../../../_images/db_manager.png

DB Manager dialog nix

Le menu Base de données vous permet de se connecter à une base de données existante, d’ouvrir une fenêtre de requête SQL et de sortir de l’extension DB manager. Une fois connecté à une base existante, les menus Schéma et Table apparaissent.

Le menu Schéma inclut des outils pour créer et pour effacer des schémas (vides) et, si la topologie est activée (par exemple dans PostGIS 2), de lancer le TopoViewer.

The Table menu allows you to create and edit tables and to delete tables and views. It is also possible to empty tables and to move tables from one schema to another. As further functionality, you can perform a VACUUM and then an ANALYZE for each selected table. Plain VACUUM simply reclaims space and makes it available for reuse. ANALYZE updates statistics to determine the most efficient way to execute a query. Finally, you can import layers/files, if they are loaded in QGIS or exist in the file system. And you can export database tables to shape with the Export File feature.

The Tree window lists all existing databases supported by QGIS. With a double-click, you can connect to the database. With the right mouse button, you can rename and delete existing schemas and tables. Tables can also be added to the QGIS canvas with the context menu.

Si une connexion à une base de données est active, la fenêtre principale de DB Manager présente trois onglets. L’onglet Info affiche les informations concernant la table et sa géométrie ainsi que mes champs, contraintes et index existants. Il est également possible d’exécuter un Vacuum Analyse et de créer un index spatial sur une table, s’il n’existe pas. L’onglet Table affiche les attributs et l’onglet Aperçu génère un aperçu des géométries.

Utilisation de la fenêtre SQL

You can also use the DB Manager to execute SQL queries against your spatial database and then view the spatial output for queries by adding the results to QGIS as a query layer. It is possible to highlight a portion of the SQL and only that portion will be executed when you press F5 or click the Execute (F5) button.

Figure DB Manager 2:

../../../_images/db_manager_sql.png

Executing SQL queries in the DB Manager SQL window nix