Skip to content

Autocomplete

  • PostgreSQL
  • MySQL
  • MariaDB

The SQL editor suggests what can come next at the cursor: keywords, schemas, tables, columns, join conditions and functions. Suggestions come from the structure of the database you are connected to, so they name your real tables and columns. Completion works in query tabs and in the SQL pane of the visual query builder.

Querybara's SQL editor on the Larchwood database with a query joining shop.orders as o and shop.customers as c. After typing "and o." on the last line, the suggestion list opens under the cursor with the orders table's columns: id (integer), customer_id, status, placed_at, shipping, total and note. The result grid below shows 696 orders still in the workshop.Querybara's SQL editor on the Larchwood database with a query joining shop.orders as o and shop.customers as c. After typing "and o." on the last line, the suggestion list opens under the cursor with the orders table's columns: id (integer), customer_id, status, placed_at, shipping, total and note. The result grid below shows 696 orders still in the workshop.
Autocomplete knows your schema: it resolves the alias o to shop.orders and offers its columns.
At the cursor Suggestions
Start of a statement, between clauses Keywords for your dialect
After FROM, JOIN, UPDATE Schemas (or databases), tables and views
After SELECT, WHERE, ON Columns of the tables in scope, qualified by their alias when one is set
After JOIN other_table alias The join condition from the foreign key between the two tables
Inside a function call Signature help with the parameter you are on highlighted
Start of a statement, in an expression Snippets saved in Querybara’s snippet library, by their prefix

Completion builds the scope of the statement under the cursor: the tables in FROM and JOIN with their aliases, CTEs, and the columns of subqueries. After o. in the statement below, the list shows the columns of shop.orders.

SELECT o. -- columns of shop.orders
FROM shop.orders o
JOIN shop.customers c ON c.id = o.customer_id;

When the tables on both sides of a join are related by a foreign key, the first suggestion is the whole condition. With a foreign key from order_items.order_id to orders.id:

SELECT * FROM shop.order_items i JOIN shop.orders o
-- suggested: ON o.id = i.order_id

Built-in functions of each dialect (string, numeric, date and time, JSON, aggregate, window and system functions) are suggested with their signatures, and so are the routines defined in your database. Inside the parentheses of a call, signature help shows the parameters and highlights the one at the cursor.

Each connection has a metadata cache in Querybara’s local store.

  • Ready at connect. When the connection opens, the cached structure goes to autocomplete at once, so suggestions work immediately. The structure is then read again from the server in the background. While it loads, the editor shows Loading metadata….
  • Refreshed after DDL. A CREATE, ALTER or DROP run from a query tab refreshes the part of the cache it changed. Inside a PostgreSQL transaction the refresh waits for COMMIT. Saving in the table designer refreshes it too, and so do Refresh on a database, schema or folder and Refresh objects on a connection in the sidebar.
  • Follows your session. USE on MySQL and MariaDB, and SET search_path on PostgreSQL, move the completion context of the tab that ran them.

On PostgreSQL the cache covers the database you are connected to. On MySQL and MariaDB it covers the current database and each database you expand in the sidebar, switch to with USE, name as a qualifier, or open a table in.

Documents Querybara 0.1.1 · built frombc9f5aa