6.11.1. Database explorer

In the database explorer the user first needs to connect to a server by choosing a connection in the first combo box (see the image below, on its top left corner) to get the list of available databases. Once connected, the second combo box will be filled up with the name of all accessible databases. The database explorer is able to manage several database instances, to do so just change the current connection in order to get a new list of databases.

When a item is selected in the database list it'll be automatically browsed creating a new tab with the name of the selected database (see the tab named demodb in the image below). Browsing a database will cause a tree of objects to be created representing the hierarchy existent there. Any element in the tree can be handled by right-clicking it and activating one of the actions available on the pop-up menu as highlighted in the image. Note that the actions in the menu may vary according to the selected object in the tree.

Another useful component in the database explorer is the object's attributes grid right below the objects' tree. This special widget stores the meta data of any object in the database in a (key, value) form. The list of attributes vary according to the kind of the selected object. For grouping items, for instance, Table (3), the attributes grid is not displayed. All actions and controls available for the database explorer are detailed below.

Database explorer controls and actions

Control/Action Description
Connections combo This combo stores all configured connections that can be used to browse databases. A connection is performed automatically when selecting an item in the listing. In order to close all opened connections and browsed databases click the button . Note that by disconnecting from all databases will cause any tab open in Database explorer or in SQL Execution to be closed.
Databases combo This combo lists all databases available for the current connection. When selecting a database in this combo it'll be automatically browsed. You can use the button aside the combo box to refresh the list of databases.
Database tab Every time a database is browsed a new tab is created with the very same name of the handled database. In this tab we have separated controls and actions in order to allow filtering and several operations over the current database. In the image above there's a set of six tool buttons at the the top of the objects tree which perform specific actions over the current database being explorer.
Filtering options The objects tree filtering can be triggered by clicking and toggling the actions Show objects filter, Show system objects, Show extension objects. The first option toggles the display of the filter fields right below the database tree. There one can use keyword in order to match items which names starts with the specified filtering term. There's a secondary option in the filter named By OID which causes the filtering keyword to be interpreted as an object id (OID) and instead of match names the ids of the database objects will be used in the comparison.

The second option toggles the display of system objects in the tree, in the same way, the third option causes extension objects to be displayed as well. Every time the user toggles these two options the tree is reloaded in order to reflect the filtering options.
Sort database objects The items in the database objects tree can be sorted by toggling the button . When this option is checked the objects are sorted alphabetically, while unchecked, causes the objects to be sorted by their OID.
Open data manipulation dialog By clicking the button or hitting the shortcut Alt+G you can access the data manipulation window in order to handle table or view data in different ways. The data manipulation dialog is detailed in the last section of this chapter.
New SQL execution tab By clicking the button or using the shortcut Ctrl+F6 opens a new SQL execution tab for the current database. This is useful when you need to run different commands without lose previous results or even compare the results if needed.
Update the database tree There are two ways of refreshing the database objects tree. The first, Quick refresh triggered by Alt+F5, updates the database tree until schema level. Objects under schemas such as tables, views, functions, data types and many others aren't displayed. In order to show children of schemas one should expand an schema item manually so the subtree of that object is updated on demand.

The second way to refresh the tree is through Full refresh action or by hitting Ctrl+F5 which causes the database tree to be populated with all objects in the database from roles to columns. This operation takes much longer to perform depending on the size of the database being managed so use it wisely. Additionally, both actions can be triggered from the the icon .
Drop the database In order to drop the currently browsed database click the button . Note that this action will completely wipe out any data related to the database so make sure to have a backup before proceed.
Attributes grid This grid displays the main attributes of an object. The available attributes and values vary according to the object selected in the tree. Multiple values for the same attributes are stored in a combo box.
Show raw attributes This option causes the user friendly names assigned to object's attributes to be hidden and the internal names to be exposed. This is useful if you intend to create snippets using object's attributes as placeholders. Details about snippets creation can be seen in the Snippets settings at Chapter 4.
Toggling attributes and source At the bottom of the database explorer widget there are two toggle buttons labeledAttributes and Source code which toggles, respectively, the attributes grid and the object's source code panel in the SQL execution widget. The state of these buttons are persisted which means that in the next execution pgModeler will be restore the visibility state of the controls related to them.

Pop-up menu actions

Control/Action Description
Update Refreshes the current selected item. If the item is a grouping one all the children will be updated as well.
Show data Opens the data manipulation dialog with the first 1000 rows loaded. This action is available only for tables and views. The data manipulation dialog is detailed in the last section of this chapter.
Reload properties Causes the properties or attributes grid to be refreshed.
Rename Triggers the object renaming action. The selected item enters in the name change mode until the Enter is pressed to confirm the new name. In order to cancel the renaming the user must hit Esc.
Drop object Drops the selected object from the database by calling the DROP command over it. If the object is referenced by any other the drop will fail due to references breaking. In order to drop the selected object and its references use the action Drop cascade.
Drop cascade Drops the selected object and its references from the database. This action will destroy more objects than selected by the user so take extreme care when using it.
Truncate This action will completely wipe out any data from the selected table by calling a TRUNCATE command over the object. If the data in table is referenced by others the truncate operation will fail due to references breaking. In order to truncate the selected table and its references use the action Trunc. cascade.
Trunc. cascade This action will completely wipe out any data from the selected table and its references. This action will wipe out all data of the selected table and its references so take extreme care when using it.
Snippets This special submenu lists the available snippets for the currently selected object. When selecting a parsable snippet from the listing the values from object's attributes will be used in the snippet's placeholders.

Mar 21, 2020 at 17:07