Starting with v0.104.0, backend scripts are disabled by default to reduce the attack surface. See Security for more information.

The SQL Console is Trilium's built-in database editor.

It can be accessed by going to the Global menu → Advanced → Open SQL Console.

### Interaction

- Hovering the mouse over one of the tables listed at the top of the document will show the columns and their data type.
- Only one SQL statement can be run at once.
- To run the statement, press the Execute icon.
- For queries that return a result, the data will displayed in a table.
- For statements (e.g. `INSERT`, `UPDATE`), the number of affected rows is displayed.

### Interacting with the table

After executing a query, a table with the results will be displayed:

- Clicking on a column allows sorting ascending or descending.
- Underneath each column there is an input field which allows filtering by text.
- Press `Ctrl`+`C` to copy the current cell to clipboard.
- Multiple cells can be selected by dragging or by holding `Shift` + arrow keys
- Results are paginated for performance reasons. The controls at the bottom of the table can be used to navigate through pages.

### Saved SQL console

SQL queries or commands can be saved into a dedicated note.

To do so, simply write the query and press the button. Once saved, the note will appear in Day Notes by default. It is possible to change the default location of saved queries by assigning a `#sqlConsoleHome` label.

The note can be locked for editing by pressing the Lock button in the note actions section near the title bar (on the New Layout, or in the Floating buttons area if using the old layout). When editing is locked, the SQL statement is hidden from view.