PgAdmin 4 9.13 with AI Assistant Panel

2026-03-1011:589536www.pgadmin.org

The Query Tool is a powerful, feature-rich environment that allows you to execute arbitrary SQL commands and review the result set. You can access the Query Tool via the Query Tool menu option on the…

The Query Tool is a powerful, feature-rich environment that allows you to execute arbitrary SQL commands and review the result set. You can access the Query Tool via the Query Tool menu option on the Tools menu, or through the context menu of select nodes of the Object explorer control. The Query Tool allows you to:

  • Issue ad-hoc SQL queries.

  • Execute arbitrary SQL commands.

  • Edit the result set of a SELECT query if it is updatable.

  • Displays current connection and transaction status as configured by the user.

  • Save the data displayed in the output panel to a CSV file.

  • Review the execution plan of a SQL statement in either a text, a graphical format or a table format (similar to https://explain.depesz.com).

  • View analytical information about a SQL statement.

Query tool window

You can open multiple copies of the Query tool in individual tabs simultaneously. To close a copy of the Query tool, click the X of the tab.

The Query Tool features two panels:

  • The upper panel displays the SQL Editor. You can use the panel to enter, edit, or execute a query or a script. It also shows the History tab which can be used to view the queries that have been executed in the session, a Scratch Pad which can be used to hold text snippets during editing, and an AI Assistant tab for generating SQL from natural language (when AI is configured). If the Scratch Pad is closed, it can be re-opened (or additional ones opened) by right-clicking in the SQL Editor and other panels and adding a new panel.

  • The lower panel displays the Data Output panel. The tabbed panel displays the result set returned by a query, information about a query’s execution plan, server messages related to the query’s execution and any asynchronous notifications received from the server.

The workspace layout offers a distraction-free, dedicated area for the Query Tool. When the Query Tool workspace is accessed, the Welcome page opens by default.

Note: In the Workspace layout, all Query Tool and View/Edit Data tabs open within the Query Tool workspace.

In the classic UI, users must connect to a database server and navigate to the database node before using the Query Tool. However, with the introduction of the Workspace layout and Welcome page, users can seamlessly connect to any ad-hoc server, even if it is not registered in the Object Explorer.

Query tool workspace
  • Select Existing Server from the dropdown to connect to a server already listed in the Object Explorer. It is optional.

  • Provide the Server Name for ad-hoc servers.

  • Specify the IP address of the server host, or the fully qualified domain name in the Host name/address field.

  • Enter the listener port number of the server host in the Port field.

  • Use the Database field to specify the name of the database to which the client will connect.

  • Use the User field to specify the name of a user that will be used when authenticating with the server.

  • Use the Password field to provide a password that will be supplied when authenticating with the server.

  • Use the Role field to specify the name of a role that has privileges that will be conveyed to the client after authentication with the server.

  • Use the Service field to specify the service name. For more information, see Section 33.16 of the Postgres documentation.

  • Use the fields in the Connection Parameters to configure the connection parameters.

After filling in all the required fields, click the Connect & Open Query Tool button to launch the Query Tool with the provided server details. If the password is not supplied, you will be prompted to enter it.

The toolbar is described in the following subsections.

The SQL editor panel is a workspace where you can manually provide a query, copy a query from another source, or read a query from a file. The SQL editor features syntax coloring and autocompletion.

Query tool editor

To use autocomplete, begin typing your query; when you would like the Query editor to suggest object names or commands that might be next in your query, press the Control+Space key combination. For example, type “SELECT * FROM” (without quotes, but with a trailing space), and then press the Control+Space key combination to select from a popup menu of autocomplete options.

Query tool autocomplete feature

After entering a query, select the Execute script icon from the toolbar. The complete contents of the SQL editor panel will be sent to the database server for execution. To execute only a section of the code that is displayed in the SQL editor, highlight the text that you want the server to execute, and click the Execute script icon.

Query tool execute script section

You can also execute a query based on cursor position. Query tool will detect a query and underline it when cursor position changes. Now, to execute the current underlined query, hit the Execute query button on the toolbar. If a section is highlighted then it will behave like normal execute.

Query tool execute query section

The warning will appear only if Underline query at cursor? is set to False and the Underlined query execute warning? switch is set to True Preferences Query tool’s Options.

Query tool execute query warning

The message returned by the server when a command executes is displayed on the Messages tab. If the command is successful, the Messages tab displays execution details.

Query tool message panel

Options on the Edit menu offer functionality that helps with code formatting and commenting:

  • The auto-indent feature will automatically indent text to the same depth as the previous line when you press the Return key.

  • Block indent text by selecting two or more lines and pressing the Tab key.

  • Implement or remove SQL style or toggle C style comment notation within your code.

You can also drag and drop certain objects from the treeview which can save time in typing long object names. Text containing the object name will be fully qualified with schema. Double quotes will be added if required. For functions and procedures, the function name along with parameter names will be pasted in the Query Tool.

Use the Query History tab to review activity for the current session:

Query tool history panel

The Query History tab displays information about recent commands:

  • The date and time that a query was invoked.

  • The text of the query.

  • The number of rows returned by the query.

  • The amount of time it took the server to process the query and return a result set.

  • Messages returned by the server (not noted on the Messages tab).

  • The source of the query (indicated by icons corresponding to the toolbar).

You can show or hide the queries generated internally by pgAdmin (during ‘View/Edit Data’ or ‘Save Data’ operations).

You can remove a single query by selecting it and clicking on the Remove button. If you would like to remove all of the histories from the Query History tab, then click on the Remove All button.

By using the Copy button, you can copy a particular query to the clipboard, and with the Copy to Query Editor button, you can copy a specific query to the Query Editor tab. During this operation, all existing content in the Query Editor is erased.

Query History is maintained across sessions for each database on a per-user basis when running in Query Tool mode. In View/Edit Data mode, history is not retained. By default, the last 20 queries are stored for each database. This can be adjusted in config_local.py or config_system.py (see the config.py documentation) by overriding the MAX_QUERY_HIST_STORED value. See the Deployment section for more information.

The AI Assistant tab provides a chat-style interface for generating SQL queries from natural language descriptions. This feature requires an AI provider to be configured in Preferences > AI. For configuration details, see the Preferences documentation.

Query tool AI Assistant panel

To use the AI Assistant:

  1. Click on the AI Assistant tab in the upper panel, or use the AI Assistant toolbar button.

  2. Type a description of the SQL query you need in natural language.

  3. Press Enter or click the send button to submit your request.

  4. The AI will analyze your database schema and generate appropriate SQL.

The AI Assistant displays conversations with your messages and AI responses. When the AI generates SQL, it appears in a syntax-highlighted code block with action buttons:

  • Insert - Insert the SQL at the current cursor position in the SQL Editor.

  • Replace - Replace all content in the SQL Editor with the generated SQL.

  • Copy - Copy the SQL to the clipboard.

The AI Assistant maintains conversation context, allowing you to refine queries iteratively. For example, you can ask for a query and then follow up with “also add a filter for active users” to modify the previous result.

Tips for effective use:

  • Be specific about table and column names if you know them.

  • Describe the desired output format (e.g., “show count by category”).

  • For complex queries, break down requirements step by step.

  • Use the Clear button to start a fresh conversation.

Note: The AI Assistant uses database schema inspection tools to understand your database structure. It supports SELECT, INSERT, UPDATE, DELETE, and DDL statements. All generated queries should be reviewed before execution.

The Data Output panel displays data and statistics generated by the most recently executed query.

Query tool output panel

The Data Output tab displays the result set of the query in a table format. You can:

  • Select and copy from the displayed result set.

  • Use the Save results to file icon to save the content of the Data Output tab as a comma-delimited file.

  • Edit the data in the result set of a SELECT query if it is updatable.

  • Move between pages of data result.

A result set is updatable if:

  • All columns are either selected directly from a single table, or are not table columns at all (e.g. concatenation of 2 columns). Only columns that are selected directly from the table are editable, other columns are read-only.

  • All the primary key columns or OIDs of the table are selected in the result set.

Any columns that are renamed or selected more than once are also read-only.

Editable and read-only columns are identified using pencil and lock icons (respectively) in the column headers.

Query tool editable and read-only columns

The psycopg2 driver version should be equal to or above 2.8 for updatable query result sets to work.

An updatable result set is identical to the Data Grid in View/Edit Data mode, and can be modified in the same way.

If Auto-commit is off, the data changes are made as part of the ongoing transaction, if no transaction is ongoing a new one is initiated. The data changes are not committed to the database unless the transaction is committed.

If any errors occur during saving (for example, trying to save NULL into a column with NOT NULL constraint) the data changes are rolled back to an automatically created SAVEPOINT to ensure any previously executed queries in the ongoing transaction are not rolled back.

All rowsets from previous queries or commands that are displayed in the Data Output panel will be discarded when you invoke another query; open another Query Tool tab to keep your previous results available.

To generate the Explain or Explain Analyze plan of a query, click on Explain or Explain Analyze button in the toolbar.

More options related to Explain and Explain Analyze can be selected from the drop down on the right side of Explain Analyze button in the toolbar.

Query tool toolbar explain button

Please note that pgAdmin generates the Explain [Analyze] plan in JSON format.

Note: If multiple queries are present and none is selected, Explain [Analyze] runs the query located at the cursor position.

On successful generation of Explain plan, it will create three tabs/panels under the Explain panel.

Please note that EXPLAIN VERBOSE cannot be displayed graphically. Click on a node icon on the Graphical tab to review information about that item; a popup window will display on the right side with the information about the selected object. For information on JIT statistics, triggers and a summary, click on the button on top-right corner; a similar popup window will be displayed when appropriate.

Use the download button on top left corner of the Explain canvas to download the plan as an SVG file.

Note: Download as SVG is not supported on Internet Explorer.

Query tool graphical explain plan

Note that the query plan that accompanies the Explain analyze is available on the Data Output tab.

Table tab shows the plan details in table format, it generates table format similar to explain.depesz.com. Each row of the table represent the data for a Explain Plan Node. It may contain the node information, exclusive timing, inclusive timing, actual vs planned rows differences, actual rows, planned rows, loops.

background color of the exclusive, inclusive, and Rows X columns may vary based on the difference between actual vs planned.

If percentage of the exclusive/inclusive timings of the total query time is: > 90 - Red color > 50 - Orange (between red and yellow) color > 10 - Yellow color

If planner mis-estimated number of rows (actual vs planned) by 10 times - Yellow color 100 times - Orange (between Red and Yellow) color 1000 times - Red color

Query tool explain plan table

Statistics tab shows two tables: 1. Statistics per Plan Node Type 2. Statistics per Table

Query tool explain plan statistics

The AI Insights tab provides AI-powered analysis of query execution plans, identifying performance bottlenecks and suggesting optimizations. This tab is only available when an AI provider is configured in Preferences > AI.

Query tool explain plan AI insights

When you switch to the AI Insights tab, the AI analyzes the execution plan and provides:

Performance Bottlenecks - Issues identified in the query plan, such as:

  • Sequential scans on large tables that could benefit from indexes

  • Significant differences between estimated and actual row counts

  • Expensive sort or hash operations

  • Nested loops with high iteration counts

Recommendations - Concrete suggestions to improve query performance:

  • Index creation statements with appropriate columns

  • ANALYZE commands to update table statistics

  • Configuration parameter adjustments

  • Query restructuring suggestions

Each recommendation that includes SQL (such as CREATE INDEX statements) has action buttons to Copy the SQL to the clipboard or Insert it into the Query Editor.

Click the Regenerate button to request a fresh analysis of the current plan.

Note: AI analysis is generated on-demand when you first click the AI Insights tab or when a new explain plan is generated while the tab is active. The analysis provides guidance but all suggested changes should be carefully evaluated before applying to production databases.

Use the Messages tab to view information about the most recently executed query:

Query tool output messages

If the server returns an error, the error message will be displayed on the Messages tab, and the syntax that caused the error will be underlined in the SQL editor. If a query succeeds, the Messages tab displays how long the query took to complete and how many rows were retrieved:

Query tool output information

Use the Notifications tab to view the notifications using PostgreSQL Listen/ Notify feature. For more details see PostgreSQL documentation.

Example:

  1. Execute LISTEN “foo” in first Query Tool session

Query tool notifications listen

2. In the another Query Tool session, execute Notify command or pg_notify function to send the notification of the event together with the payload.

Query tool notifications notify

3. You can observe the Notification tab in the first Query Tool session where it shows the Recorded time, Event, Process ID, and the Payload of the particular channel.

Query tool notifications panel

Click the Graph Visualiser button in the toolbar to generate the Graphs of the query results. The graph visualiser supports Line Charts, Stacked Line Charts, Bar Charts, Stacked Bar Charts, and Pie Charts.

Query tool graph visualiser panel

Choose the type of the graph that you would like to generate.

Query tool graph visualiser graph type

Choose the column whose value you wish to display on X-axis from the X Axis dropdown. Select the <Row Number> option to use the number of rows as labels on the X-axis.

Query tool graph visualiser xaxis

Choose the columns whose value you wish to display on Y-axis from the Y Axis dropdown. Users can choose multiple columns. Choose the <Select All> option from the drop-down menu to select all the columns.

Query tool graph visualiser yaxis

Zooming is performed by clicking and selecting an area over the chart with the mouse. The Zoom to original button will bring you back to the original zoom level.

Click the Download button on the button bar to download the chart.

Query tool graph visualiser toolbar

The Line Chart can be generated by selecting the ‘Line Chart’ from the Graph Type drop-down, selecting the X-axis and the Y-axis, and clicking on the ‘Generate’ button. Below is an example of a chart of employee names and their salaries.

Query tool graph visualiser line chart

Set Use different data point styles? option to true in the Preferences, to show data points in a different style on each graph lines.

The Stacked Line Chart can be generated by selecting the ‘Stacked Line Chart’ from the Graph Type drop-down, selecting the X-axis and the Y-axis, and clicking on the ‘Generate’ button.

Query tool graph visualiser stacked line chart

The Bar Chart can be generated by selecting the ‘Bar Chart’ from the Graph Type drop-down, selecting the X-axis and the Y-axis, and clicking on the ‘Generate’ button.

Query tool graph visualiser bar chart

The Stacked Bar Chart can be generated by selecting the ‘Stacked Bar Chart’ from the Graph Type drop-down, selecting the X-axis and the Y-axis, and clicking on the ‘Generate’ button.

Query tool graph visualiser stacked bar chart

The Pie Chart can be generated by selecting the ‘Pie Chart’ from the Graph Type drop-down, selecting the Label and Value, and clicking on the ‘Generate’ button.

Query tool graph visualiser pie chart

Use the Connection status feature to view the current connection and transaction status by clicking on the status icon in the Query Tool:

Query tool connection and transaction statuses

User can connect to another server or database from existing open session of query tool.

  • Click on the connection link next to connection status.

  • Now click on the <New Connection> option from the dropdown.

Query tool connection options
  • Now select server, database, user, and role to connect and click on the ‘Save’ button.

Query tool connection dialog
  • A newly created connection will now get listed in the options.

  • To connect, select the newly created connection from the dropdown list.

Query Tool Macros enable you to execute pre-defined SQL queries with a single key press. Pre-defined queries can contain the placeholder $SELECTION$. Upon macro execution, the placeholder will be replaced with the currently selected text in the Query Editor pane of the Query Tool.

Query Tool Manage macros

To create a macro, select the Manage Macros option from the Macros menu on the Query Tool. Select the key you wish to use, enter the name of the macro, and the query, optionally including the selection placeholder, and then click the Save button to store the macro.

Query Tool Manage Macros dialogue

To add a query to macros, write and select your query, then go to the Macros menu in the Query Tool and click Add to macros. Your query will be automatically saved to macros.

Query Tool Add To Macros

To delete a macro, select the macro on the Manage Macros dialogue, and then click the Delete button. The server will prompt you for confirmation to delete the macro.

Query Tool Manage Macros Clear row confirmation

To execute a macro, simply select the appropriate shortcut keys, or select it from the Macros menu.

Query Tool Macros Execution

Server-side cursors allow partial retrieval of large datasets, making them particularly useful when working with very large result sets. However, they may offer lower performance in typical, everyday usage scenarios.

To enable server-side cursors:

  • Go to Preferences > Query Tool > Options and set “Use server cursor?” to True.

  • Alternatively, you can enable it on a per-session basis via the Query Tool’s Execute menu.

Query Tool Server Cursor

Limitations:

1. Transaction Requirement: Server-side cursors work only in transaction mode. If enabled pgAdmin will automatically ensure queries run within a transaction.

  1. Limited Use Case: Use server-side cursors only when fetching large datasets.

3. Pagination Limitation: In the Result Grid, the First and Last page buttons will be disabled, as server-side cursors do not return a total row count. Consequently, the total number of rows will not be displayed after execution.


Page 2


Page 3

Use the Table dialog to create or modify a table.

The Table dialog organizes the development of a table through the following dialog tabs: General, Columns, Constraints, Advanced, Parition, Parameter, and Security. The SQL tab displays the SQL code generated by dialog selections.

Table dialog general tab

Use the fields in the General tab to identify the table:

  • Use the Name field to add a descriptive name for the table. A table cannot have the same name as any existing table, sequence, index, view, foreign table, or data type in the same schema. The name specified will be displayed in the pgAdmin tree control. This field is required.

  • Select the owner of the table from the drop-down listbox in the Owner field. By default, the owner of the table is the role that creates the table.

  • Select the name of the schema in which the table will reside from the drop-down listbox in the Schema field.

  • Use the drop-down listbox in the Tablespace field to specify the tablespace in which the table will be stored.

  • Move the Partitioned Table? switch to the Yes in case you want to create a partitioned table. Option is available for PostgreSQL 10 and above.

  • Store notes about the table in the Comment field.

Click the Columns tab to continue.

Table dialog columns tab

Use the drop-down listbox next to Inherited from table(s) to specify any parent table(s); the table will inherit columns from the selected parent table(s). Click inside the Inherited from table(s) field to select a table name from a drop-down list. Repeat to add any other parent tables. Delete a selected table by clicking the x to the left of the parent name. Note that inherited column names and datatypes are not editable in the current dialog; they must be modified at the parent level.

Click the Add icon (+) to specify the names of columns and their datatypes in the Columns table:

  • Use the Name field to add a descriptive name for the column.

  • Use the drop-down listbox in the Data type field to select a data type for the column. This can include array specifiers. For more information on the data types supported by PostgreSQL, refer to Chapter 8 of the core documentation.

  • If enabled, use the Length/Precision and Scale fields to specify the maximum number of significant digits in a numeric value, or the maximum number of characters in a text value.

  • Move the Not NULL? switch to the Yes position to require a value in the column field.

  • Move the Primary key? switch to the Yes position to specify the column is the primary key constraint.

Click the Add icon (+) to add additional columns; to discard a column, click the trash icon to the left of the row and confirm deletion in the Delete Row popup.

Click the Constraints tab to continue.

Table dialog constraints tab

Use the fields in the Constraints tab to provide a table or column constraint. Optional constraint clauses specify constraints (tests) that new or updated rows must satisfy for an INSERT or UPDATE operation to succeed. Select the appropriate constraint type by selecting one of the following tabs on the Constraints panel:

Tab Name

Constraint

Primary Key

Provides a unique identifier for each row in the table.

Foreign Key

Maintains referential integrity between two tables.

Check

Requires data satisfies an expression or condition before insertion or modification.

Unique

Ensures that the data contained in a column, or a group of columns, is unique among all the rows in the table.

Exclude

Guarantees that if any two rows are compared on the specified column or expression (using the specified operator), at least one of the operator comparisons will return false or null.

To add a primary key for the table, select the Primary Key tab, and click the Add icon (+). To define the primary key, click the Edit icon to the left of the Trash icon. A dialog similar to the Primary key dialog (accessed by right clicking on Constraints in the pgAdmin tree control) opens.

Use the fields in the General tab to identify the primary key:

  • Use the Name field to add a descriptive name for the primary key constraint. The name will be displayed in the pgAdmin tree control.

  • Provide notes about the primary key in the Comment field.

Click the Definition tab to continue.

Table dialog primary key constraint definition

Use the fields in the Definition tab to define the primary key constraint:

  • Click inside the Columns field and select one or more column names from the drop-down listbox. To delete a selection, click the x to the left of the column name. The primary key constraint should be different from any unique constraint defined for the same table; the selected column(s) for the constraints must be distinct.

  • Select the name of the tablespace in which the primary key constraint will reside from the drop-down listbox in the Tablespace field.

  • Use the Fill Factor field to specify a fill factor for the table and index. The fill factor for a table is a percentage between 10 and 100. 100 (complete packing) is the default.

  • Move the Deferrable? switch to the Yes position to specify the timing of the constraint is deferrable and can be postponed until the end of the statement. The default is No.

  • If enabled, move the Deferred? switch to the Yes position to specify the timing of the constraint is deferred to the end of the statement. The default is No.

Table dialog foreign key constrain

To add a foreign key constraint, select the Foreign Key tab, and click the Add icon (+). To define the constraint, click the Edit icon to the left of the Trash icon. A dialog similar to the Foreign key dialog (accessed by right clicking on Constraints in the pgAdmin tree control) opens.

Use the fields in the General tab to identify the foreign key constraint:

  • Use the Name field to add a descriptive name for the foreign key constraint. The name will be displayed in the pgAdmin tree control.

  • Provide notes about the foreign key in the Comment field.

Click the Definition tab to continue.

Table dialog foreign key constraint definition

Use the fields in the Definition tab to define the foreign key constraint:

  • Move the Deferrable? switch to the Yes position to specify the timing of the constraint is deferrable and can be postponed until the end of the statement. The default is No.

  • If enabled, move the Deferred? switch to the Yes position to specify the timing of the constraint is deferred to the end of the statement. The default is No.

  • Move the Match type switch specify the type of matching that is enforced by the constraint:

    • Select Full to indicate that all columns of a multicolumn foreign key must be null if any column is null; if all columns are null, the row is not required to have a match in the referenced table.

    • Select Simple to specify that a single foreign key column may be null; if any column is null, the row is not required to have a match in the referenced table.

  • Move the Validated switch to the Yes position to instruct the server to validate the existing table content (against a foreign key or check constraint) when you save modifications to this dialog.

  • Move the Auto FK Index switch to the No position to disable the automatic index feature.

  • The field next to Covering Index generates the name of an index if the Auto FK Index switch is in the Yes position; or, this field is disabled.

Click the Columns tab to continue.

Table dialog foreign key constraint columns
Use the fields in the Columns tab to specify one or more reference column(s).

A Foreign Key constraint requires that one or more columns of a table must only contain values that match values in the referenced column(s) of a row of a referenced table:

  • Use the drop-down listbox next to Local column to specify the column in the current table that will be compared to the foreign table.

  • Use the drop-down listbox next to References to specify the name of the table in which the comparison column(s) resides.

  • Use the drop-down listbox next to Referencing to specify a column in the foreign table.

Click the Add icon (+) to add a column to the list; repeat the steps above and click the Add icon (+) to add additional columns. To discard an entry, click the trash icon to the left of the entry and confirm deletion in the Delete Row popup.

Click the Action tab to continue.

Table dialog foreign key constraint action

Use the drop-down listboxes on the Action tab to specify behavior related to the foreign key constraint that will be performed when data within the table is updated or deleted:

  • Use the drop-down listbox next to On update to select an action that will be performed when data in the table is updated.

  • Use the drop-down listbox next to On delete to select an action that will be performed when data in the table is deleted.

The supported actions are:

NO ACTION

Produce an error indicating that the deletion or update will create a foreign key constraint violation. If the constraint is deferred, this error will be produced at constraint check time if any referencing rows still exist. This is the default.

RESTRICT

Throw an error indicating that the deletion or update would create a foreign key constraint violation. This is the same as NO ACTION except that the check is not deferrable.

CASCADE

Delete any rows referencing the deleted row, or update the values of the referencing column(s) to the new values of the referenced columns, respectively.

SET NULL

Set the referencing column(s) to null.

SET DEFAULT

Set the referencing column(s) to their default values. There must be a row in the referenced table that matches the default values (if they are not null), or the operation will fail.

Table dialog check constraint

To add a check constraint, select the Check tab on the panel, and click the Add icon (+). To define the check constraint, click the Edit icon to the left of the Trash icon. A dialog similar to the Check dialog (accessed by right clicking on Constraints in the pgAdmin tree control) opens.

Use the fields in the General tab to identify the check constraint:

  • Use the Name field to add a descriptive name for the check constraint. The name will be displayed in the pgAdmin tree control. With PostgreSQL 9.5 forward, when a table has multiple check constraints, they will be tested for each row in alphabetical order by name and after NOT NULL constraints.

  • Provide notes about the check constraint in the Comment field.

Click the Definition tab to continue.

Table dialog check constraint definition

Use the fields in the Definition tab to define the check constraint:

  • Provide the expression that a row must satisfy in the Check field. This field is required.

  • Move the No Inherit? switch to the Yes position to specify that this constraint is not automatically inherited by a table’s children. The default is No, meaning that the constraint will be inherited by any children.

  • Move the Don’t validate? switch to the No position to skip validation of existing data; the constraint may not hold for all rows in the table. The default is Yes.

Table dialog unique constraint

To add a unique constraint, select the Unique tab on the panel, and click the Add icon (+). To define the constraint, click the Edit icon to the left of the Trash icon. A dialog similar to the Unique constraint dialog (accessed by right clicking on Constraints in the pgAdmin tree control) opens.

Use the fields in the General tab to identify the unique constraint:

  • Use the Name field to add a descriptive name for the unique constraint. The name will be displayed in the pgAdmin tree control.

  • Provide notes about the unique constraint in the Comment field.

Click the Definition tab to continue.

Table dialog unique constraint definition

Use the fields in the Definition tab to define the unique constraint:

  • Click inside the Columns field and select one or more column names from the drop-down listbox. To delete a selection, click the x to the left of the column name. The unique constraint should be different from the primary key constraint defined for the same table; the selected column(s) for the constraints must be distinct.

  • Select the name of the tablespace in which the unique constraint will reside from the drop-down listbox in the Tablespace field.

  • Use the Fill Factor field to specify a fill factor for the table and index. The fill factor for a table is a percentage between 10 and 100. 100 (complete packing) is the default.

  • Move the Deferrable? switch to the Yes position to specify the timing of the constraint is deferrable and can be postponed until the end of the statement. The default is No.

  • If enabled, move the Deferred? switch to the Yes position to specify the timing of the constraint is deferred to the end of the statement. The default is No.

Table dialog exclude constraint

To add an exclusion constraint, select the Exclude tab on the panel, and click the Add icon (+). To define the constraint, click the Edit icon to the left of the Trash icon. A dialog similar to the Exclusion constraint dialog (accessed by right clicking on Constraints in the pgAdmin tree control) opens.

Use the fields in the General tab to identify the exclusion constraint:

  • Use the Name field to provide a descriptive name for the exclusion constraint. The name will be displayed in the pgAdmin tree control.

  • Provide notes about the exclusion constraint in the Comment field.

Click the Definition tab to continue.

Table dialog exclusion constraint definition

Use the fields in the Definition tab to define the exclusion constraint:

  • Use the drop-down listbox next to Tablespace to select the tablespace in which the index associated with the exclude constraint will reside.

  • Use the drop-down listbox next to Access method to specify the type of index that will be used when implementing the exclusion constraint:

    • Select gist to specify a GiST index (the default).

    • Select spgist to specify a space-partitioned GiST index.

    • Select btree to specify a B-tree index.

    • Select hash to specify a hash index.

  • Use the Fill Factor field to specify a fill factor for the table and associated index. The fill factor is a percentage between 10 and 100. 100 (complete packing) is the default.

  • Move the Deferrable? switch to the Yes position to specify that the timing of the constraint is deferrable, and can be postponed until the end of the statement. The default is No.

  • If enabled, move the Deferred? switch to the Yes position to specify the timing of the constraint is deferred to the end of the statement. The default is No.

  • Use the Constraint field to provide a condition that a row must satisfy to be included in the table.

Click the Columns tab to continue.

Table dialog exclusion constraint columns

Use the fields in the Columns tab to specify the column(s) to which the constraint applies. Use the drop-down listbox next to Column to select a column and click the Add icon (+) to provide details of the action on the column:

  • The Column field is populated with the selection made in the Column drop-down listbox.

  • If applicable, use the drop-down listbox in the Operator class to specify the operator class that will be used by the index for the column.

  • Move the DESC switch to DESC to specify a descending sort order. The default is ASC which specifies an ascending sort order.

  • Move the NULLs order switch to LAST to define an ascending sort order for NULLs. The default is FIRST which specifies a descending order.

  • Use the drop-down list next to Operator to specify a comparison or conditional operator.

Click the Advanced tab to continue.

Table dialog advanced tab

Use the fields in the Advanced tab to define advanced features for the table:

  • Move the RLS Policy? switch to the Yes position to enable the Row Level Security.

  • Move the Force RLS Policy? to the Yes position to force the policy on the owner of the table.

  • Use the drop-down listbox next to Of type to copy the table structure from the specified composite type. Please note that a typed table will be dropped if the type is dropped (with DROP TYPE … CASCADE).

  • Use the drop-down list box next to Access Method to specify the table access method to use to store the contents for the new table; the method needs to be an access method of type TABLE. This field is optional. This option is available from v12 and above.

  • Use the Fill Factor field to specify a fill factor for the table. The fill factor for a table is a percentage between 10 and 100. 100 (complete packing) is the default.

  • Use the Toast tuple target field to set toast_tuple_target storage parameter of the table. The toast_tuple_target value is in bytes and has minimum value of 128. This field will be enabled only for PostgreSQL version >= 11

  • Use the Parallel workers field to set parallel_workers storage parameter of the table. The parallel_workers sets the number of workers that should be used to assist a parallel scan of the table. This field will be enabled only for PostgreSQL version >= 9.6

  • Move the Has OIDs? switch to the Yes position to specify that each row within a table has a system-assigned object identifier. The default is No.

  • Move the Unlogged? switch to the Yes position to disable logging for the table. Data written to an unlogged table is not written to the write-ahead log. Any indexes created on an unlogged table are automatically unlogged as well. The default is No.

Use the fields in the Like box to specify which attributes of an existing table from which a table will automatically copy column names, data types, and not-null constraints; after saving the new or modified table, any changes to the original table will not be applied to the new table.

  • Use the drop-down listbox next to Relation to select a reference table.

  • Move the switch next to With default values? to the Yes position to copy default values.

  • Move the switch next to With constraints? to the Yes position to copy table and column constraints.

  • Move the switch next to With indexes? to the Yes position to copy indexes.

  • Move the switch next to With storage? to the Yes position to copy storage settings.

  • Move the switch next to With comments? to the Yes position to copy comments.

  • Move the switch next to With compression? to the Yes position to copy compression method. This option is available only on PostgreSQL 14 and above.

  • Move the switch next to With generated? to the Yes position to copy generation expressions of copied column. This option is available only on PostgreSQL 12 and above.

  • Move the switch next to With identity? to the Yes position to copy any identity specifications of copied column.

  • Move the switch next to With statistics? to the Yes position to copy extended statistics.

With PostgreSQL 10 forward, the Partition tab will be visible.

Click the Partition tab to continue.

Table dialog partition tab

Use the fields in the partition tab to create the partitions for the table:

  • Select a partition type from the Partition Type selection box. There are 3 options available; Range, List and Hash. Hash option will only enable for PostgreSQL version >= 11.

Use the Partition Keys panel to define the partition keys. Click the Add icon (+) to add each partition keys selection:

  • Select a partition key type in the Keytype field.

  • Select a partition column in the Column field if Column option selected for Keytype field .

  • Specify the expression in the Expression field if Expression option selected for the Keytype field.

Use the Partitions panel to define the partitions of a table. Click the Add icon (+) to add each partition:

  • Move the Operation switch to attach to attach the partition, by default it is create.

  • Use the Name field to add the name of the partition.

  • If partition type is Range or List then Default field will be enabled.

  • If partition type is Range then From and To fields will be enabled.

  • If partition type is List then In field will be enabled.

  • If partition type is Hash then Modulus and Remainder fields will be enabled.

Users can create a partition and define them as a partitioned table. Click the Edit icon to expand the properties of a partition. Use the Partition tab to create that partition as a partitioned table.

  • Move the Partitioned Table? switch to the Yes in case you want to create a partitioned table.

  • Select a partition type from the Partition Type selection box.

  • Use the Partition Keys panel to define the partition keys.

View of multi level Partitioned Table in object explorer:

Table dialog partition tree

Click the Parameter tab to continue.

Table dialog parameter tab

Use the tabs nested inside the Parameter tab to specify VACUUM and ANALYZE thresholds; use the Table tab and the Toast Table tab to customize values for the table and the associated toast table:

  • Move the Custom auto-vacuum? switch to the Yes position to perform custom maintenance on the table and to select values in the Vacuum table. The Vacuum Table provides default values for maintenance operations.

  • Changing Autovacuum enabled? to Not set will reset autovacuum_enabled.

Provide a custom value in the Value column for each metric listed in the Label column.

Click the Security tab to continue.

Table dialog security tab

Use the Security tab to assign privileges and define security labels.

Use the Privileges panel to assign privileges to a role. Click the Add icon (+) to set privileges for database objects:

  • Select the name of the role from the drop-down listbox in the Grantee field.

  • Click inside the Privileges field. Check the boxes to the left of one or more privileges to grant the selected privilege to the specified user.

  • The current user, who is the default grantor for granting the privilege, is displayed in the Grantor field.

Click the Add icon (+) to assign additional privileges; to discard a privilege, click the trash icon to the left of the row and confirm deletion in the Delete Row popup.

Use the Security Labels panel to define security labels applied to the function. Click the Add icon (+) to add each security label selection:

  • Specify a security label provider in the Provider field. The named provider must be loaded and must consent to the proposed labeling operation.

  • Specify a security label in the Security Label field. The meaning of a given label is at the discretion of the label provider. PostgreSQL places no restrictions on whether or how a label provider must interpret security labels; it merely provides a mechanism for storing them.

Click the Add icon (+) to assign additional security labels; to discard a security label, click the trash icon to the left of the row and confirm deletion in the Delete Row popup.

Click the SQL tab to continue.

Your entries in the Table dialog generate a SQL command (see an example below). Use the SQL tab for review; revisit or switch tabs to make any changes to the SQL command.

The following is an example of the sql command generated by user selections in the Table dialog:

Table dialog sql tab

The example shown demonstrates creating a table named jobhist. It has six columns and a primary key constraint on the empno and startdate column.

  • Click the Info button (i) to access online help.

  • Click the Save button to save work.

  • Click the Close button to exit without saving work.

  • Click the Reset button to restore configuration parameters.


Page 4

Use the Rule dialog to define or modify a rule for a specified table or view. A PostgreSQL rule allows you to define an additional action that will be performed when a SELECT, INSERT, UPDATE, or DELETE is performed against a table.

The Rule dialog organizes the development of a rule through the General, Definition, Condition, Commands tabs. The SQL tab displays the SQL code generated by dialog selections.

Rule dialog general tab

Use the fields in the General tab to identify the rule:

  • Use the Name field to add a descriptive name for the rule. The name will be displayed in the pgAdmin tree control. Multiple rules on the same table are applied in alphabetical name order.

  • Store notes about the rule in the Comment field.

Click the Definition tab to continue.

Rule dialog definition tab

Use the fields in the Definition tab to write parameters:

  • Click inside the Event field to select the type of event that will invoke the rule; event may be Select, Insert, Update, or Delete.

  • Move the Do Instead switch to Yes indicate that the commands should be executed instead of the original command; if Do Instead specifies No, the rule will be invoked in addition to the original command.

Trigger enabled in dialog tab
  • Rule enabled field is available in rule dialog once the rule is created. You can select one of the four options available.

Click the Condition tab to continue.

Rule dialog condition tab

Specify a SQL conditional expression that returns a boolean value in the editor.

Click the Commands tab to continue.

Rule dialog commands tab

Provide a command in the editor that defines the action performed by the rule.

Click the SQL tab to continue.

Your entries in the Rule dialog generate a SQL command (see an example below). Use the SQL tab for review; revisit or switch tabs to make any changes to the SQL command.

The following is an example of the sql command generated by user selections in the Rule dialog:

Rule dialog sql tab
  • Click the Info button (i) to access online help.

  • Click the Save button to save work.

  • Click the Close button to exit without saving work.

  • Click the Reset button to restore configuration parameters.


Page 5

Use the Trigger dialog to create a trigger or modify an existing trigger. A trigger executes a specified function when certain events occur.

The Trigger dialog organizes the development of a trigger through the following dialog tabs: General, Definition, Events, and Code. The SQL tab displays the SQL code generated by dialog selections.

Trigger dialog general tab

Use the fields in the General tab to identify the trigger:

  • Use the Name field to add a descriptive name for the trigger. This must be distinct from the name of any other trigger for the same table. The name will be displayed in the pgAdmin tree control. Note that if multiple triggers of the same kind are defined for the same event, they will be fired in alphabetical order by name.

  • Store notes about the trigger in the Comment field.

Click the Definition tab to continue.

Trigger dialog definition tab

Use the fields in the Definition tab to define the trigger:

  • Move the Row trigger? switch to the No position to disassociate the trigger from firing on each row in a table. The default is Yes.

  • Move the Constraint trigger? switch to the Yes position to specify the trigger is a constraint trigger.

  • If enabled, move the Deferrable? switch to the Yes position to specify the timing of the constraint trigger is deferrable and can be postponed until the end of the statement. The default is No.

  • If enabled, move the Deferred? switch to the Yes position to specify the timing of the constraint trigger is deferred to the end of the statement causing the triggering event. The default is No.

  • Use the drop-down listbox next to Trigger Function to select a trigger function or procedure.

  • Use the Arguments field to provide an optional (comma-separated) list of arguments to the function when the trigger is executed. The arguments are literal string constants.

Trigger enabled in dialog tab
  • Trigger enabled field is available in trigger dialog once the trigger is created. You can select one of the four options available.

Click the Events tab to continue.

Trigger dialog events tab

Use the fields in the Events tab to specify how and when the trigger fires:

  • Use the drop-down listbox next to the Fires fields to determine if the trigger fires BEFORE or AFTER a specified event. The default is BEFORE.

  • Select the type of event(s) that will invoke the trigger; to select an event type, move the switch next to the event to the YES position. The supported event types are INSERT, UPDATE, DELETE, and TRUNCATE.

  • Use the When field to provide a boolean condition that will invoke the trigger.

  • If defining a column-specific trigger, use the Columns field to specify the columns or columns that are the target of the trigger.

Click the Code tab to continue.

Trigger dialog code tab

Use the Code field to specify any additional code that will be invoked when the trigger fires.

Click the SQL tab to continue.

Your entries in the Trigger dialog generate a SQL command (see an example below). Use the SQL tab for review; revisit or switch tabs to make any changes to the SQL command.

The following is an example of the sql command generated by user selections in the Trigger dialog:

Trigger dialog sql tab

The example demonstrates creating a trigger named emp_trigger.

  • Click the Info button (i) to access online help.

  • Click the Save button to save work.

  • Click the Close button to exit without saving work.

  • Click the Reset button to restore configuration parameters.


Read the original article

Comments

  • By chaz6 2026-03-1014:217 reply

    When I got the update I looked through the settings and there appears to be no way to disable it. I do not want AI anywhere near my database. I only use it for testing/staging at least so I should hopefully not have to worry about it wrecking production.

    • By imjared 2026-03-1014:353 reply

      The docs suggest that you can set the default provider to "None" to disable AI features: https://www.pgadmin.org/docs/pgadmin4/9.13/preferences.html#...

      • By smartbit 2026-03-1015:011 reply

        Note: AI features must be enabled in the server configuration

          LLM_ENABLED = True 
        
        in config.py for these preferences to be available.

        • By OptionOfT 2026-03-1016:20

          I did not enable this and yet I got the panel in the UI.

      • By zenmac 2026-03-1015:001 reply

        It is nice that they have the default set to "None". However to have this feature in pgAmdin is as distraction from the project.

        If it is just calling API anyway, then I don't want to have this in my db admin tool. It also expose surface area of potential data leakage.

        • By bensyverson 2026-03-1015:05

          Worth pointing out that Postgres is perfectly usable without an admin dashboard at all

    • By ziml77 2026-03-1014:422 reply

      What's the danger? It can see the schemas to help it generate the queries but it can't run anything on its own. Also you have to give the application credentials to an AI provider for the feature to work. So, you can just not do that.

      • By adamas 2026-03-1015:04

        There is no need of potential dangers to not want to have non-deterministic features in an application.

      • By justinclift 2026-03-1021:521 reply

        > What's the danger?

        Hallucinated ideas about what needs doing, what commands to run, etc.

        So, data that's no longer reliable (ie could be subtly changed), or even outright data loss.

        • By Natfan 2026-03-114:071 reply

          just don't accept bogus changes it suggests? this is why having a human in the loop is a very good idea

          • By justinclift 2026-03-1111:59

            Yep, I fully agree. It'd be awesome if all (or even most?) of the users were immune to automation bias though. :)

            https://en.wikipedia.org/wiki/Automation_bias

            And hopefully the users who are using this aren't YOLO-ing it. Though I'm pretty sure we're all expecting there will be a sizeable percentage who are.

    • By forinti 2026-03-1116:09

      It's there on the UI, but it doesn't do anything if it's not enabled.

    • By giancarlostoro 2026-03-1022:23

      If you arent using it is it even a danger?

    • By lateforwork 2026-03-1017:082 reply

      Did you miss this:

      "This feature requires an AI provider to be configured in Preferences > AI."

      And then you have to supply an API key (see here https://www.pgedge.com/blog/ai-features-in-pgadmin-configura... )

      You don't get AI for free!

      • By chaz6 2026-03-1214:42

        When I open a new query window, the AI tab is selected by default which is annoying. I just want to write SQL without having to switch tabs like I could before. Not only has it ruined my muscle memory, it's also more inefficient.

      • By stuaxo 2026-03-1119:25

        You can use it with Ollama rubbing a local model.

    • By rubicon33 2026-03-1015:26

      Why do you do in production?

  • By panzi 2026-03-1016:101 reply

    Yeah, no thanks. I switched to dbeaver already anyway, because pgadmin was annoying about to which postgres versions it could connect. Too much of a hassle to setup a new version from source back when I tried. With dbeaver I just run ./dbeaver from the extracted .tag.gz. dbeaver is also not a web interface, but a real desktop application (Java, though).

    • By forinti 2026-03-1115:581 reply

      I run pgAdmin with docker and there's almost nothing to it.

      When a new version comes out, I just update the image version on the stack yml.

      • By panzi 2026-03-1122:07

        The fact that you need Docker to make it easy is already a mayor failure. What happened to single binary programs that you can just run? I don't want a whole virtualized OS installation just to get a desktop application to work.

  • By vavkamil 2026-03-1015:09

    Quick fix based on https://github.com/pgadmin-org/pgadmin4/issues/9696#issuecom...

    Click on the "Reset layout" button in the query tool (located in the top right corner), and it will move the "AI Assistant" tab to the right. Now, when you query a table, it will default to the Query tab as always.

HackerNews