{"id":107357,"date":"2025-07-23T13:00:00","date_gmt":"2025-07-23T13:00:00","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=107357"},"modified":"2025-07-21T11:27:05","modified_gmt":"2025-07-21T11:27:05","slug":"using-pgadmin-to-work-with-azure-database-for-postgresql-flexible-server","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/postgresql\/using-pgadmin-to-work-with-azure-database-for-postgresql-flexible-server\/","title":{"rendered":"How to use pgAdmin with Azure Database for PostgreSQL flexible server"},"content":{"rendered":"\n<p>Multiple tools are available for working with <a href=\"https:\/\/azure.microsoft.com\/en-us\/products\/postgresql\" target=\"_blank\" rel=\"noreferrer noopener\">Azure Database for PostgreSQL flexible server<\/a>. One of these is the psql command-line utility, which <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/postgresql\/getting-started-with-azure-database-for-postgresql-flexible-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">I introduced you to in the previous article in this series<\/a>. Another valuable tool is <a href=\"https:\/\/www.pgadmin.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">pgAdmin<\/a>, a much more robust product. It provides a graphical user interface (GUI) for managing and querying PostgreSQL instances, including ADP flexible server. The tool enables DBAs, developers, and other users to easily interact with their ADP instances, while providing intuitive features for working with databases and their data.<\/p>\n\n\n\n<p>If you\u2019ve used <a href=\"https:\/\/learn.microsoft.com\/en-us\/ssms\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server Management Studio<\/a> to work with SQL Server, you\u2019ll find many similar features in pgAdmin. For example, you can easily navigate database objects or quickly modify those objects in a few steps. The pgAdmin interface enables you to perform a wide range of tasks using simple point-and-click operations. You can also create and execute scripts, as well as run individual SQL statements. In addition, pgAdmin includes a built-in version of the psql tool, making it easy to switch between the GUI environment and a command-line interface, all within a single window.<\/p>\n\n\n\n<p>As with any tool, the best way to learn about pgAdmin is through hands-on experience. To help you get started, this article explains numerous features in pgAdmin and demonstrates their use. You\u2019ll learn how to define a connection to an ADP instance and navigate the server and database object hierarchy. You\u2019ll also learn how to create database objects and how to launch a query window and run SQL statements. In addition, I\u2019ll demonstrate how you can launch psql so you can work from the command line within the pgAdmin window.<\/p>\n\n\n\n<p><strong>Note<\/strong>: To follow along with the examples in this article, you need to have a running ADP instance and know the necessary connection information, including the full endpoint name, port number, user name, password, and target database. If you haven\u2019t set up ADP yet, refer to the <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/postgresql\/getting-started-with-azure-database-for-postgresql-flexible-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">first article<\/a> in this series.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-install-pgadmin-on-your-system\">How to install pgAdmin on your system<\/h2>\n\n\n\n<p>Before you can use pgAdmin to connect to ADP flexible server, you must install it on your computer. You can run pgAdmin on Windows, macOS, and Linux computers, as well as in <a href=\"https:\/\/www.docker.com\/resources\/what-container\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker containers<\/a>. The installation process will depend on the platform you choose. The best place to start is by going to the <a href=\"https:\/\/www.pgadmin.org\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">pgAdmin Download page<\/a>, which provides the information you need for installing pgAdmin on different systems.<\/p>\n\n\n\n<p>To prepare for this article, I installed pgAdmin on my Mac, which was a very straightforward process. I clicked the <strong>macOS<\/strong> link on the Download page, and downloaded the .dmg installation file for the latest pgAdmin release, which is currently version 9.4. I then opened the file to launch the installation process and followed the prompts. Once that was complete, I opened pgAdmin and was ready to go.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-step-by-step-guide-to-connecting-pgadmin-to-azure-postgresql-flexible-server\">Step-by-step guide to connecting pgAdmin to Azure PostgreSQL flexible server<\/h2>\n\n\n\n<p>When you first launch pgAdmin, you\u2019re presented with two main sections, as shown in the following figure. The left section is a pane that contains Object Explorer. This is where you\u2019ll navigate the object hierarchy after you\u2019ve connected to a PostgreSQL instance. Initially, it includes only the <strong>Servers<\/strong> node:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"511\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-9-1024x511.png\" alt=\"The servers node in pgAdmin.\" class=\"wp-image-107358\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-9-1024x511.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-9-300x150.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-9-768x383.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-9.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The right section is the main window where you\u2019ll carry out many of your operations. When you open pgAdmin, the window contains only the <strong>Dashboard<\/strong> tab and <strong>Properties<\/strong> tab. The <strong>Dashboard<\/strong> tab provides links for connecting to a server instance and for configuring pgAdmin. It also provides links to additional information. The <strong>Properties<\/strong> tab contains object properties. However, it will show few details at this point. As with Object Explorer, you need to connect to a PostgreSQL instance before you can view any meaningful information.<\/p>\n\n\n\n<p>To connect to your ADP instance, click the <strong>Add<\/strong> <strong>New<\/strong> <strong>Server<\/strong> link on the <strong>Dashboard<\/strong> tab. This will launch the <strong>Register &#8211; Server<\/strong> dialog box, where you can enter the connection information for your ADP instance. This is the same information you used in the previous article when establishing a connection in psql. The following figure shows the <strong>General<\/strong> tab in the <strong>Register &#8211; Server<\/strong> dialog box, where you should enter a name for your connection. I named my connection <strong>adp<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"811\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-10-1024x811.png\" alt=\"The Register - Server dialog box in pgAdmin.\" class=\"wp-image-107359\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-10-1024x811.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-10-300x238.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-10-768x608.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-10.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>For now, you can leave all the other options on the <strong>General<\/strong> tab at their default values. Next, go to the <strong>Connection<\/strong> tab and configure the following settings:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><strong>Host name\/address.<\/strong> Specify the address that Azure generated for your ADP instance. For my instance, I used adpserver.postgres.database.azure.com.<\/li>\n\n\n\n<li><strong>Port.<\/strong> Use port 5432 for your ADP instances.<\/li>\n\n\n\n<li><strong>Maintenance database.<\/strong> Use the default database, postgres, for this connection. You can still work with other databases after you connect to your ADP instance.<\/li>\n\n\n\n<li><strong>Username.<\/strong> Enter the PostgreSQL administrative account name you specified when you created your ADP instance. For my ADP instance, I created the adpadmin account.<\/li>\n\n\n\n<li><strong>Password. <\/strong>Enter the password for the PostgreSQL administrative account.<\/li>\n\n\n\n<li><strong>Save password.<\/strong> Enable this option if you don\u2019t want to be prompted for a password every time you connect to the server instance.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>You can leave the other options at their default values for now. The following figure shows the <strong>Connection<\/strong> tab after I configured it on my system. Once you\u2019ve configured all the options, click <strong>Save<\/strong> to create the connection and connect to your ADP instance:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"814\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-11-1024x814.png\" alt=\"Connecting to an ADP instance in pgAdmin.\" class=\"wp-image-107360\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-11-1024x814.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-11-300x238.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-11-768x610.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-11.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After you\u2019re connected to your ADP instance, you can access the server and database objects in Object Explorer and carry out a wide range of other tasks. For example, you can create databases and their tables, add data to those tables, and retrieve and modify that data.<\/p>\n\n\n\n<p><strong>Note.<\/strong> The pgAdmin documentation sometimes refers to Object Explorer as Tree Control. For this article and those to follow, I\u2019ll stick with Object Explorer because that is the name used in the interface.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h-navigating-object-explorer-in-pgadmin\">Navigating Object Explorer in pgAdmin<\/h1>\n\n\n\n<p>When you connect to your ADP instance, the connection you defined is listed as a subnode beneath the <strong>Servers<\/strong> node in Object Explorer. For example, I named my connection <strong>adp<\/strong>, so after I connected to my ADP instance, Object Explorer listed the <strong>adp<\/strong> subnode under the <strong>Servers<\/strong> node, as shown in the following figure:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-12-1024x512.png\" alt=\"Object Explorer in pgAdmin, after connecting to an ADP instance.\" class=\"wp-image-107361\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-12-1024x512.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-12-300x150.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-12-768x384.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-12.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In this figure, the <strong>adp<\/strong> connection is expanded to display the three top-level categories in the server\u2019s object hierarchy:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><strong>Databases.<\/strong> The system and user databases that currently exist on your PostgreSQL instance. When you first create an ADP instance, PostgreSQL creates the following three databases: azure_maintenance, azure_sys, and postgres. The node does not show the template databases.<\/li>\n\n\n\n<li><strong>Login\/Group Roles.<\/strong> The user and group roles that are defined at the cluster level. These are shared by all databases in the cluster. Here you can manage them and assign privileges and memberships. We\u2019ll be digging more deeply into user and group roles later in the series.<\/li>\n\n\n\n<li><strong>Tablespaces.<\/strong> The tablespaces that are defined on the server instance. A tablespace is an alternative storage location on the filesystem for storing database objects such as tables and indexes.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>The <strong>Databases<\/strong> node in the figure is also expanded to show the three databases. In all likelihood, you\u2019ll be spending the majority of your time working with the <strong>Databases<\/strong> node, where you can access the objects specific to each database. For example, if you expand the <strong>postgres<\/strong> node, you can drill down into the various subnodes, such as <strong>Catalogs<\/strong>, <strong>Event<\/strong> <strong>Triggers<\/strong>, <strong>Extensions<\/strong>, and <strong>Schemas<\/strong>, as shown in the following figure:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"751\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-13.png\" alt=\"Various subnodes of the postgres node in Object Explorer in pgAdmin.\" class=\"wp-image-107362\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-13.png 434w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-13-173x300.png 173w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-managing-databases-and-schemas-in-pgadmin\">Managing databases and schemas in pgAdmin<\/h2>\n\n\n\n<p>As we work through this series, we\u2019ll be digging into the different object types in more detail, but for now, let\u2019s focus on the <strong>Schemas<\/strong> node, which is where you\u2019ll find the database tables.<\/p>\n\n\n\n<p><strong>Note.<\/strong> At the top of Object Explorer, you\u2019ll see a set of icons for quickly accessing database tools such as the Query Tool or PSQL Tool, which we\u2019ll be getting to shortly. The tools are available only if you\u2019ve selected a database node or one of its subnodes in Object Explorer.<\/p>\n\n\n\n<p>When a database is added to an ADP instance, the service creates the public schema, which serves as the default schema when adding tables or other database objects. The ADP service might also add other schemas. For example, the service creates both the cron and public schemas for the postgres database, as shown in the following figure. The cron schema is used to store metadata related to scheduled jobs. You can also create your own schemas for organizing database objects:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"443\" height=\"871\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-14.png\" alt=\"Creating your own schema in pgAdmin.\" class=\"wp-image-107363\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-14.png 443w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-14-153x300.png 153w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/figure>\n\n\n\n<p>The figure also shows the <strong>public<\/strong> schema node expanded. When you expand a schema, you can drill into the object nodes associated with that schema, such as <strong>Aggregations<\/strong>, <strong>Collations<\/strong>, <strong>Sequences<\/strong>, and <strong>Tables<\/strong>. Once again, I\u2019ll be spending more time on these concepts as we progress through this series. Just know that if you create any objects in the public schema, they will be listed in their associated node. For example, if you add a table to the public schema in the postgres database, it will be listed beneath the <strong>Tables<\/strong> node.<\/p>\n\n\n\n<p>When you connect to a PostgreSQL instance, the <strong>Dashboard<\/strong> tab displays multiple panels, with the <strong>Activity<\/strong> panel selected by default, as shown in the following figure. The <strong>Activity<\/strong> panel displays graphs that provide real-time information about current server or database activity, based on the node selected in Object Explorer. In this case, the <strong>adp<\/strong> connection node is selected, so the activity reflects the entire server instance. If you were to select a database in Object Explorer, the graphs would be specific to that database:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"669\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-15-1024x669.png\" alt=\"Selecting a database in Object Explorer in pgAdmin.\" class=\"wp-image-107364\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-15-1024x669.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-15-300x196.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-15-768x502.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-15.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In addition to the <strong>Activity<\/strong> panel, the <strong>Dashboard<\/strong> tab includes four other panels:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><strong>State.<\/strong> Provides details about sessions, locks, and prepared transactions. The information is specific to the node selected in Object Explorer.<\/li>\n\n\n\n<li><strong>Configuration.<\/strong> Displays the current server configuration settings.<\/li>\n\n\n\n<li><strong>Logs.<\/strong> Lists the server logs. You must be granted permission to the pg_stat_file function to view the logs. I\u2019ll be discussing permissions and logging later in this series.<\/li>\n\n\n\n<li><strong>System.<\/strong> Displays system statistics about the CPU, memory, and storage resources. To view the statistics, the system_stats extension must be installed. I\u2019ll be discussing extensions later in this series.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>The main pgAdmin window also includes the <strong>Properties<\/strong> tab, which displays the property settings for the node selected in Object Explorer. For example, the following figure shows the properties for the <strong>adp<\/strong> connection, which is selected in Object Explorer. If a different object were selected, the properties would be specific to that.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"937\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-16-1024x937.png\" alt=\"The Properties tab in the main pgAdmin window.\" class=\"wp-image-107365\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-16-1024x937.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-16-300x274.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-16-768x702.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-16.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The pgAdmin interface also lets you configure settings (preferences) for the tool\u2019s environment. To access the settings, click the <strong>Settings<\/strong> button in the bottom left corner of the pgAdmin interface. This will launch the <strong>Preferences<\/strong> dialog box, shown in the following figure:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"755\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-17-1024x755.png\" alt=\"The Preferences dialog box in pgAdmin.\" class=\"wp-image-107366\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-17-1024x755.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-17-300x221.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-17-768x566.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-17.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The settings are organized into multiple categories, such as <strong>Browser<\/strong>, <strong>Debugger<\/strong>, <strong>Query<\/strong> <strong>Tool<\/strong>, and <strong>Storage<\/strong>. Each category contains a set of related configuration subcategories, and each subcategory contains a set of related settings that you can configure for your environment.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Using the pgAdmin GUI to create database objects<\/h1>\n\n\n\n<p>The pgAdmin interface provides point-and-click capabilities for creating database objects and working with data. Many DBAs and other advanced users will likely focus more on running SQL scripts and other commands directly, rather than using GUI features, but it is still a good idea to be familiar with these options.<\/p>\n\n\n\n<p>For example, you can use point-and-click features to create a table in the postgres database. To create a table, drill down to <strong>Databases &gt; postgres &gt; Schemas &gt; public &gt; Tables<\/strong> in Object Explorer. Right-click the <strong>Tables<\/strong> node and click <strong>Create &gt; Table<\/strong>. This will launch the <strong>Create &#8211; Table<\/strong> dialog box, with the <strong>General<\/strong> tab selected, as shown in the following figure:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"637\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-18-1024x637.png\" alt=\"The General tab selected within the Create - Table dialog box in pgAdmin.\" class=\"wp-image-107367\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-18-1024x637.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-18-300x187.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-18-768x478.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-18.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I\u2019ve already provided a name for the table (test1), but you can use a different name. I\u2019ve also left all the other options with their default settings, which you don\u2019t need to be concerned with at this point.<\/p>\n\n\n\n<p>Next, go to the <strong>Columns<\/strong> tab and define a couple of columns. For example, the following figure shows the two columns I defined\u2014col1 and col2\u2014which are configured with the smallint and text data types, respectively. To add a column, click the plus sign near the upper right corner. This adds a row, where you can fill in the necessary details. For this example, I kept it simple and provided only the column names and data types:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-19-1024x640.png\" alt=\"Defining columns under the Column tab in pgAdmin.\" class=\"wp-image-107368\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-19-1024x640.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-19-300x187.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-19-768x480.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-19.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once you\u2019ve defined your table, click the <strong>Save<\/strong> button. PostgreSQL will then add the table to the database and list it beneath the <strong>Tables<\/strong> node in Object Explorer. To delete the table, right-click it in Object Explorer and click <strong>Delete<\/strong>. When prompted to confirm your deletion, click <strong>Delete<\/strong> again.<\/p>\n\n\n\n<p>You can do a lot more with the GUI capabilities in pgAdmin, such as create other objects, return a table\u2019s data, or import or export data. Most operations are fairly intuitive. I suggest that you try out different GUI capabilities to get a better sense of what you can do.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h-running-sql-queries-using-pgadmin-s-query-tool\">Running SQL queries using pgAdmin&#8217;s Query Tool<\/h1>\n\n\n\n<p>One of the handiest features in pgAdmin is <a href=\"https:\/\/www.pgadmin.org\/docs\/pgadmin4\/8.14\/query_tool.html\" target=\"_blank\" rel=\"noreferrer noopener\">Query Tool<\/a>, which you can use to run SQL statements and SQL scripts against your ADP server instance. You must launch the tool within the context of a specific database. It will then provide you with a workspace for interacting in real-time with that database. You can change the database context, if necessary, but not as easily as you can in SQL Server or MySQL because they both support the <a href=\"https:\/\/surrealdb.com\/docs\/surrealql\/statements\/use\" target=\"_blank\" rel=\"noreferrer noopener\">USE statement<\/a>. PostgreSQL does not.<\/p>\n\n\n\n<p>To launch Query Tool, select the target database or one of its nodes in Object Explorer, and then click the <strong>Query<\/strong> <strong>Tool<\/strong> icon at the top of Object Explorer. You can also launch the tool by right-clicking the node and then clicking <strong>Query Tool<\/strong>. The tool will open in its own tab in the main pgAdmin window, as shown in the following figure. You can open multiple Query Tool tabs if necessary, which can be useful when carrying out certain task. For example, you might want to compare the results of two different queries or query two different databases.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"773\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-20-1024x773.png\" alt=\"Comparing different databases in pgAdmin.\" class=\"wp-image-107369\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-20-1024x773.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-20-300x227.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-20-768x580.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-20.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In Query Tool, you can run any SQL statement that is supported by PostgreSQL. For information about how SQL is implemented in PostgreSQL, refer to the support document: <a href=\"https:\/\/www.postgresql.org\/docs\/current\/sql.html\" target=\"_blank\" rel=\"noreferrer noopener\">Part II. The SQL Language<\/a>.<\/p>\n\n\n\n<p>An important feature of Query Tool is the toolbar at the top of the tab, which is shown in the following figure. The toolbar includes a number of icons that enable you to carry out tasks such as saving or opening a script file, editing the current script, or executing one or more statements.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"91\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-21-1024x91.png\" alt=\"The toolbar at the top of the tab in Query Tool in pgAdmin.\" class=\"wp-image-107370\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-21-1024x91.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-21-300x27.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-21-768x68.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-21.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>As you can see, I\u2019ve outlined two of toolbar options in red because I wanted to call these out specifically. The two options enable you to execute SQL statements and scripts in different ways:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><strong>Execute script.<\/strong> The first of the two options executes all the SQL script in the <strong>Query<\/strong> pane, unless some of the code is selected (highlighted), in which case it will execute only the selected code.<\/li>\n\n\n\n<li><strong>Execute query.<\/strong> The second option executes the SQL statement in which the cursor is currently positioned. However, it will instead execute only the highlighted code, if any is selected, just like the <strong>Execute script<\/strong> icon.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>The PostgreSQL topic <a href=\"https:\/\/www.pgadmin.org\/docs\/pgadmin4\/latest\/query_tool_toolbar.html#query-execution\" target=\"_blank\" rel=\"noreferrer noopener\">Query Tool Toolbar<\/a> provides a detailed breakdown of the different options on the toolbar and the shortcuts available for those options.<\/p>\n\n\n\n<p>To try out Query Tool, select the <strong>postgres<\/strong> database node in Object Explorer, and click the <strong>Query<\/strong> <strong>Tool<\/strong> icon at the top of Object Explorer. When the Query Tool tab appears, type the following code in the <strong>Query<\/strong> pane and click the <strong>Execute<\/strong> <strong>script<\/strong> icon on the toolbar:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">CREATE TABLE tbl (col1 smallint, col2 text);<\/pre><\/div>\n\n\n\n<p>The <strong>Messages<\/strong> pane should display a message indicating that the statement successfully executed. You can then verify that the table has been created by checking the <strong>Tables<\/strong> node in Object Explorer. You might need to refresh the node to see the new table. To do so, right-click the node and click <strong>Refresh<\/strong>. The new table should now be listed as one of the tables.<\/p>\n\n\n\n<p>After you create the table, insert a couple lines after the CREATE TABLE statement in the <strong>Query<\/strong> pane and then type the following INSERT statement, which will add data to the new table:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">INSERT INTO tbl \nvalues \n  (101, 'abc'),\n  (102, 'def'),\n  (103, 'ghi'),\n  (104, 'jkl'),\n  (105, 'mno');\n<\/pre><\/div>\n\n\n\n<p>To execute the INSERT statement only (and not the CREATE TABLE statement again), place your cursor within the statement or directly after it and then click the <strong>Execute<\/strong> <strong>query<\/strong> icon on the toolbar. This will insert the data into the table and return a message indicating that the data has been added. You can then run the following SELECT statement to confirm that the data has been inserted:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">SELECT * FROM tbl;<\/pre><\/div>\n\n\n\n<p>When you query data in this way, the results are displayed in the <strong>Data Output<\/strong> pane, as shown in the following figure. Notice that the pane includes its own toolbar for working with the query results. The toolbar includes icons for carrying out tasks such as adding a row, copying or pasting data, or saving the results to a file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"416\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-22-1024x416.png\" alt=\"The Data Output pane in Query Tool in pgAdmin.\" class=\"wp-image-107371\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-22-1024x416.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-22-300x122.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-22-768x312.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-22.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After you\u2019re finished experimenting with the <strong>Data<\/strong> <strong>Output<\/strong> options, delete the table by running the following DROP TABLE statement:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:tsql decode:true \">DROP TABLE tbl;<\/pre><\/div>\n\n\n\n<p>You can confirm that the table has been deleted by right-clicking the <strong>Tables<\/strong> node in Object Explorer and then clicking <strong>Refresh<\/strong>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Working with psql in the pgAdmin GUI<\/h1>\n\n\n\n<p>One other pgAdmin feature I want to point out is the built-in psql utility, which you learned about in the last article. The psql feature\u2014referred to as PSQL Tool in pgAdmin\u2014lets you interact directly with an ADP instance, just like you saw with the version of psql that you run in your system\u2019s command-line interface (CLI).<\/p>\n\n\n\n<p>To launch PSQL Tool, select the target database or one of its nodes in Object Explorer, and then click the <strong>PSQL<\/strong> <strong>Tool<\/strong> icon at the top of Object Explorer. You can also launch the tool by right-clicking the node and then clicking <strong>PSQL Tool<\/strong>. The utility will open in its own tab in the main pgAdmin window, as shown in the following figure. As with Query Tool, you can open multiple PSQL Tool tabs if necessary.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"288\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-23-1024x288.png\" alt=\"PSQL Tool in pgAdmin.\" class=\"wp-image-107372\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-23-1024x288.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-23-300x84.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-23-768x216.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/07\/image-23.png 1090w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In this case, the tool was opened in the context of the postgres database, as indicated by the command prompt. I took this screenshot after I ran the same the CREATE TABLE statement you saw earlier. As with Query Tool, you can run any of the SQL statements supported by PostgreSQL. You can also run psql meta-commands (described in the previous article).<\/p>\n\n\n\n<p>Being able to switch between Query Tool and PSQL Tool offers greater flexibility for working with your ADP instances. You can use each one in whatever way best suits your current needs and workflow. The pgAdmin interface also has the advantage of providing Object Explorer, which gives you an immediate visual of your database objects, along with quick and easy access to those objects.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h-next-steps-and-what-s-to-come\">Next steps, and what&#8217;s to come<\/h1>\n\n\n\n<p>As you\u2019ve seen in this article, pgAdmin offers a powerful and feature-rich interface for working with ADP instances and other PostgreSQL deployments. However, we\u2019ve barely skimmed the surface on the many ways you can use pgAdmin to work with PostgreSQL. I encourage you to play around the tool to get more comfortable with how to use it and the many features it offers. You can find more information about the tool in the <a href=\"https:\/\/www.pgadmin.org\/docs\/pgadmin4\/latest\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">pgAdmin docs<\/a>, which cover many aspects of pgAdmin.<\/p>\n\n\n\n<p>As we progress through this series, I\u2019ll be relying on pgAdmin to explain concepts and demonstrate different operations. Many of the examples will be demonstrated in Query Tool and PSQL Tool. The better you understand how these tools work and how to navigate Object Explorer, the more time you can spend learning about ADP and getting the most out of your PostgreSQL instance.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to connect and manage Azure PostgreSQL Flexible Server using pgAdmin, a powerful GUI tool for PostgreSQL.&hellip;<\/p>\n","protected":false},"author":221841,"featured_media":107392,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143523,143534],"tags":[5364,159354,4168,4170,159353,158978,4150,4151],"coauthors":[6779],"class_list":["post-107357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databases","category-postgresql","tag-azure","tag-azure-database-for-postgresql-flexible-server","tag-database","tag-database-administration","tag-pgadmin","tag-postgresql","tag-sql","tag-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/107357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/221841"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=107357"}],"version-history":[{"count":9,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/107357\/revisions"}],"predecessor-version":[{"id":107395,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/107357\/revisions\/107395"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media\/107392"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=107357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=107357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=107357"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=107357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}