Help › Run queries

Choose a tab's connection and database

See which connection and database a query tab uses, change them, start a tab on a particular database, and know what a tab does when it has none.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

Every query tab runs on one connection, and in one database of that connection's server. The bar above the editor shows both at its right: the connection's name, then the database. The status bar names the connection too, with its environment.

The tab itself names its database after its title, in lighter text, such as Query 1 shop, so you can tell tabs on different databases apart; a long name is cut short. It changes when the tab's database does. Point at the tab to see its database, connection and engine in full. A tab on a connection with only one database (SQLite, DuckDB, Oracle Database, the scratch) shows nothing more, as the connection already says which. In screen-share mode the tab shows the database's placeholder instead of its name.

See and change a tab's connection

Click the connection's name in the bar above the editor. The list shows your saved connections grouped by environment, each with a dot for its state (connected, connecting, failed or not connected). Choose one.

Or select a connection in the sidebar and choose Query › Use Selected Connection in This Tab.

The tab's next statement runs on the new connection, in a new session, in that connection's database. Querlyn connects when the statement needs it.

See and change a tab's database

A tab starts in the database the connection names, or once connected the one the server reports, which is the server's default when the connection names none. To run the tab's statements in another database of the same server, click the database's name in the bar above the editor and choose one, or choose Query › Choose Database for This Tab… and pick it from the list.

The list has the server's databases as the sidebar lists them: on MySQL, MariaDB and ClickHouse, what the sidebar shows as schemas, which those databases call databases. Their own system databases are listed last.

What the tab's session does depends on the database:

DatabaseWhat happens
PostgreSQL, Amazon Redshift, Azure SQL DatabaseA session stays in the database it connected to, so the tab gets a new session in the chosen database at its next statement. Its temporary tables and session settings are not carried over.
MySQL, MariaDB, SQL Server, ClickHouse, SnowflakeThe tab keeps its session, which moves to the chosen database (USE) before its next statement. Its variables and temporary tables stay.
MongoDBThe tab keeps its session; the chosen database is the db of its next statements, as use name in the editor makes it.
CassandraThe databases are keyspaces. The tab keeps its session, which moves to the chosen keyspace (USE) before its next statement.
SQLite, DuckDB, Oracle DatabaseA connection has one database. The bar shows it, and it cannot be changed.
BigQueryThe databases are projects. The tab's queries run, and are billed, in the chosen project. A tab that keeps a BigQuery session (temporary tables, variables, a transaction) stays in its project; open another tab for another one.

Completion, the editor's checks of table and column names, Explain and the keys used to edit rows all follow the tab's database at once.

When a statement in the tab changes database itself (USE reporting on MySQL or SQL Server), the bar follows.

When Querlyn does not change them

Querlyn does not change a tab's connection or database while that would lose something or run it in the wrong place, and says what to do first:

The tab hasDo this first
A running queryCancel it.
An open transaction, when you change its connectionCommit it or roll it back.
A dry run waiting for Commit or Roll BackCommit it or roll it back.
Row changes in the results that are not appliedApply them or revert them.
An export still runningWait for it to finish, or cancel it.

Change database with a transaction open

When the tab has an open transaction and you choose another database, Querlyn asks first, because the transaction's changes are in the database the tab is on now:

  • Commit and Switch commits them, then moves the tab.
  • Roll Back and Switch undoes them, then moves the tab.
  • Cancel keeps the tab, and its transaction, where they are.

The tab moves only once the commit or the rollback has succeeded. If the commit fails, the tab stays where it was, its transaction still open, and the status bar says why. A transaction that failed can only be rolled back, so then the question offers Roll Back and Switch and Cancel. On Production, Commit and Switch is red.

Transactions that a run on several connections holds open are on those connections' own sessions, so they do not stop the tab from changing database.

Start a tab on a particular database

Right-click a database, a schema or a table in the sidebar and choose New Query: the tab is on that database. On a connection the same command is New Query on This Connection, and the tab is on the connection's own database. It is also Query › New Query on This Connection, which acts on what is selected in the sidebar.

A query tab opened from something in the sidebar is on that thing's database too: a table's rows (Open a table's rows), the script of the table designer, an ER diagram or a schema comparison, and an object's definition. So is a statement opened from the query history, which runs again in the database it ran in, and one opened from Server Activity, on the database of the session it came from.

Which connection a new tab gets

A new tab takes the connection you used last: the one you last connected, chose for a tab, or opened a query on. With only one saved connection, every tab takes that one. Otherwise, until you have used any, a new tab says No connection.

If you run a statement in a tab with no connection, the tab takes the connection you used last, or else the one selected in the sidebar. If you have no connections at all, Querlyn says to create one first.

What a tab without a connection can do

You can write in it. The SQL is colored and formatted as PostgreSQL, and completion offers keywords, functions and snippets but no table names. Nothing is checked against a database.

What belongs to the tab, and what to the connection

Belongs to each tabShared by all tabs of a connection
Its database, and its session on it: transaction, temporary tables, session settings such as the search pathWhether auto-commit is on
Its resultsWhether the connection is read-only
The values you entered for parametersThe names of tables and columns Querlyn has read

Closing a tab closes its session. If the tab has an open transaction, row changes that are not applied, or an export still running, Querlyn asks first.

Help for Querlyn 0.1.0. All help topics