Help › Write SQL

Complete SQL as you type

How the editor suggests tables, columns, joins, functions, keywords and a column's values, how to accept a suggestion, and where the suggestions come from.

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

As you type, Querlyn suggests what can come next. The suggestions follow the statement you are writing: after a table's alias and a dot you get that table's columns, not every column in the database.

Use the suggestions

The list opens by itself right after you type a dot, and when you pause while typing a name. To open it anywhere, press ⌃Space on macOS or Ctrl+Space on Windows and Linux.

ToPress
Move through the list↑ on macOS or Up on Windows and Linux, ↓ on macOS or Down on Windows and Linux, ⇞ on macOS or PageUp on Windows and Linux, ⇟ on macOS or PageDown on Windows and Linux
Take the highlighted suggestion↩ on macOS or Enter on Windows and Linux or ⇥ on macOS or Tab on Windows and Linux
Close the list⎋ on macOS or Esc on Windows and Linux

When you have typed a suggestion out in full, ↩ on macOS or Enter on Windows and Linux closes the list and starts a new line, as it would without the list.

Keep typing to narrow the list. Each row has a short tag that says what the suggestion is:

TagMeaning
tbl, viewA table or a view
colA column
schA schema
alias, cteAn alias or a WITH query of the statement you are in
fn, procA function or a procedure, with its arguments
joinA whole join condition, written from a foreign key
valA value of a column; see Values of a column
keyA key of a JSON column's documents
kwA keyword
snipA snippet; see Insert snippets

Note: On macOS, the keys for asking for suggestions may be the keys that switch input sources, and then macOS takes them first. When a shortcut does not work says how to find out and what to do.

What is suggested where

You are typingYou are offered
After FROM or JOINTables and views, and the WITH queries of the statement. Tables of the schemas you are working in come first; a table from another schema is written with its schema.
After an alias and a dot (o.)The columns of that table.
After a schema and a dot (sales.)The tables in that schema.
In a select list or a WHERE clauseThe columns of the tables the statement uses, then functions and keywords.
After ON in a joinA condition for each foreign key between the two tables, such as o.customer_id = c.id.
After CALL or EXECProcedures.
After a column and =, <>, LIKE or IN (, after SET a column =, in a row of INSERT … VALUES, and in a string thereThe column's values first, then columns and functions.
After a JSON column and ->, ->>, #> or :, or as the path of JSON_VALUE and the likeThe keys of the column's documents.
At the start of a statementKeywords and snippets.

This works on SQL that is not finished or not valid yet. For example, here the list after o. holds the columns of orders, although the statement has no select list yet:

SELECT o.
FROM orders o
JOIN customers c ON o.customer_id = c.id

Details that follow what you type:

  • A keyword is inserted in the case you started it in: wh gives where, WH gives WHERE.
  • A name that needs quotes in your database, because of capitals, spaces or a reserved word, is inserted with them.
  • Tables and routines you marked as favorites or used recently come before others that match equally well.
  • With several cursors, a suggestion you take is inserted at every cursor.

Nothing is suggested inside a string, except a value where one fits (status = 'pa), or while text is selected.

Values of a column

Where a value of a column fits, the list offers values that column can hold, best first, and inserts each as your database writes it: text in quotes, numbers as they are, dates as dates (DATE '2024-01-31' where the database needs that), a JSON key in the database's path syntax ('customer'->'name' on PostgreSQL, '$.customer.name' on MySQL, SQLite, DuckDB, SQL Server and Oracle, customer.name on Snowflake).

The columnOffered
Of an enumerated type (a PostgreSQL enum, MySQL's or DuckDB's ENUM, ClickHouse's Enum8)Its members, in the order the type declares them
Limited by a check such as CHECK (kind IN ('retail', 'trade'))Those values
A booleanTRUE and FALSE (1 and 0 on SQL Server)
Text, a number or a date with few distinct values (a status, a type, a country code)Its most common values, with how many rows of the sample held each
JSONThe keys of its documents, three levels deep, with how many documents of the sample had each

The first three come from what the database says about the column, on every connection. The last two come from a sample that Querlyn reads the first time you need a column's values: one query on the connection's own metadata session (never your tab's, so never inside your transaction), over the first 10,000 rows the server returns (1,000 for JSON), stopped after five seconds. A column whose sample holds more than 100 distinct values, or whose values do not repeat, is not offered. On a database that bills by the bytes a query reads (BigQuery), a sample is read only when BigQuery estimates it at 100 MB or less. While the sample is read the list shows Loading… and then fills in.

A sample is kept in memory only: it is never written to disk, synced or logged, and it is gone when you quit. It is read again after 15 minutes, or after the table changed, the next time you need it.

  • On high-risk connections (Production) nothing is sampled until you turn it on with Command Palette › Preferences: Completion (High Risk): Sample Column Values. The first time a list could have offered sampled values there, it says so once. Command Palette › Preferences: Completion (Medium Risk): Sample Column Values and Command Palette › Preferences: Completion (Low Risk): Sample Column Values turn sampling off for the other connections. In Settings: Safety, Sample column values for completion.
  • A masked column never offers a value and is never sampled, whether screen-share mode is on or not.

Where the suggestions come from

The names come from what Querlyn has already read of the database, not from a query sent on each key press, so the list is immediate. When you connect, Querlyn reads the names of the schemas, tables and views; it reads a table's columns the first time something needs them. While that is still on its way, the list shows Loading… and fills in when the answer arrives.

  • A tab with No connection gets keywords, functions and snippets only.
  • After a change made outside Querlyn, refresh the names with Query › Refresh on the connection or schema in the sidebar.
  • The list shows at most 500 suggestions; type more letters to narrow it.

What Querlyn has read is kept on this computer between sessions, so suggestions are there as soon as you connect again. It is names and types only, never rows: samples of values stay in memory. See What is sent and stored.

Help for Querlyn 0.1.0. All help topics