4. Managing Databases

After creating a connection you can select it by clicking in the Select Connection action in the connections grid. You will see that the connection will be represented by a kind of outer tab called a Connection Tab. And this whole area is called the Workspace Window.

Sections of the Workspace window

This interface has several elements:

Connection Outer Tab

The outer table named PostgreSQL - testdb has this name because of the alias (PostgreSQL) we put in the connection to the testdb database. This tab is a Connection Outer Tab. Notice the little tab with a cross besides the PostgreSQL - testdb outer tab. This allows you to create a new outer tab that will automatically be a Connection Outer Tab. However, the Snippet Outer Tab is fixed and will always be the first.

A new Connection Outer Tab will always automatically point to the first connection on your list of database connections. Or, if you clicked on the Select Connection action, it will point to the selected connection. Observe the elements inside of this tab:

Working with databases

Take a look at your connections selector. OmniDB always points to the first available connection but you can change it by clicking on the selector.

Select the PostgreSQL connection. Now go to the tree right below the selector and click to expand the root node PostgreSQL.

Bear in mind that every 30 minutes you keep without performing actions on the database, will trigger an Authentication popup, meaning that the password that OmniDB has encrypted and stored in memory is now expired. As explained before, this is important for your database security. After you type the correct password, you will see the PostgreSQL node now shows the PostgreSQL version and also was expanded, showing the current database connection and also instance wide elements: Databases, Tablespaces, Roles and Replication Slots.

You can connect to a single PostgreSQL database, and using the same connection you can connect to other databases in the same PostgreSQL instance. The currently active database will be indicated below the connection selector.

To connect to a different database, expand the node corresponding to that database. A popup will appear asking if you really want to change the active database.

Click on Yes and OmniDB will change the active database to the database you choose. It will be reflected on the Active database indicator, and also on the outer tab name.

Go ahead and expand the Schemas node. You will see all schemas in the current database (in case of PostgreSQL, TOAST and temp schemas are not shown).

Now click to expand the schema public. You will see different kinds of elements contained in this schema.

Now click to expand the node Tables, and you will see all tables contained in the schema public. Expand any table and you will see its columns, primary key, foreign keys, constraints, indexes, rules, triggers and partitions.

In order to view records inside a table, right click it and choose *Data Actions

Query Data*.

Notice that OmniDB opens a new SQL editor with a simple query to list table records. The records are displayed in a grid right below the editor. This grid can be controlled with keyboard as if you were using a spreadsheet manager. You can also copy data from single cells or block of cells (that can be selected with the keyboard or mouse) and paste on any spreadsheet manager.

You can edit the query on the SQL editor, writing simple or more complex queries. To execute, click on the action button or hit the keystroke Alt-Q. If the results exceed 50 registers, then extra buttons Fetch More and Fetch All will appear. More details in the next chapters.

Working with multiple tabs inside the same connection

Inside a single connection, you can create several inner query tabs by clicking on the last little tab with a cross, and then choosing Query Tab.

On OmniDB, you can execute several SQL statements and procedures in parallel. When it is executing, an icon will be shown in the tab to indicate its current state. If some process is finished and it is not in the current tab, that tab will show a green icon indicating the routine being executed there is now finished.

By clicking in the Cancel button, you can cancel a process running inside the database.

You can also drag and drop a tab to change its order. This works with both inner and outer tabs.

Additionally, you can use keyboard shortcuts to manage inner tabs (SQL Query) and outer tabs (Connection):

Starting from OmniDB version 2.3.0, all SQL Query tabs are automatically saved whenever you execute them. Even if you close OmniDB window or browser tab, they are already stored in OmniDB User Database. They will be automatically restored when you open OmniDB again (if you are using app), open it in another browser window (if you are using server), or even if you clicked in the Connections window or logged out. Removing an outer tab or inner tab by the interface makes it permanently deleted, so it will not be restored.