pgAdmin

About

pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world, which includes, among others, the Postgis spatial extention.

pgAdmin is developed by a community of PostgreSQL experts around the world and is available in more than a dozen languages. It is Free Software released under the PostgreSQL License.

pgAdmin is aimed to answer the needs of all users, from writing simple SQL queries to developing complex databases. The graphical interface supports all PostgreSQL features and makes its administration easy. The application includes, among other things: syntax highlighting SQL editor, a server-side code editor, an SQL/batch/shell job scheduling agent, and much more. See more about it in the official website.

Quick start guide

Note

To execute this Quick Start Guide you will need a running instance of PostgreSQL database with the spatial extension PostGIS installed, please ask your system administrator for the connection parameters. For further information about PostgreSQL or PostGIS see Online resources.

The following quick start guide will introduce you to pgAdmin basics. It will show how to access to a spatially enabled database and run some simple queries on its tables.

  1. Download the data for this tutorial here and unzip it anywhere you think it’s convenient.

  2. Import the geodata from the shapefile into the database, if you have shp2pgsql command line utility at hand you can import the data with:

    shp2pgsql events.shp | psql -U postgres pg_test
    

    If you don’t have this command available you can still use QGIS db manager to import you data into the database.

#. Open pgAdmin4 using any of the available shortcuts in your computer.

By default, pgAdmin4 will show the following window on opening:

../_images/pgadmin_first_open.png
  1. On the Browser panel, right-click on the Servers, and navigate to Create ‣ Server... to create a new database connection.

  2. In the Create - Server dialog, enter the connection Name. Click the Connection tab, enter the connection parameters in the dialog and click Save.. figure:: img/

    A database connection is usually identified by:

    • host
    • port
    • username
    • password
    ../_images/pgadmin_register_new_server.png
  3. Click on the newly added server to open its objects tree and select the events table or any other table you want to query. Then, click the Properties tab.

    ../_images/pgadmin_schema_tree.png
  4. Perform operations on selected tables with Right-Click

    ../_images/pgadmin_right_click_table_operations.png
  5. Preview data with View Data ‣ View First 100 Rows

    ../_images/pgadmin_right_click_table_preview.png
    ../_images/pgadmin_right_click_table_preview_result.png
  6. In the menus, click Tools ‣ Query

  7. In the query editor, type the following query:

    SELECT name, St_AsText( geom ) FROM events;
    
  8. Then, click the Execute/Refresh button or press F5

    ../_images/pgadmin_execute_sql_results.png