# Use database CLI tools

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

Almost every database vendor has its own Command-Line Interface (CLI) tool. The following list shows you a couple of examples.

* PostgreSQL: `psql`

* Oracle: `sqlplus` (SQL Command Line for SQL*Plus)

* MySQL: `mysql`

* Microsoft SQL Server: `sqlcmd`

* SQLite: `sqlite3`

To use these tools in GoLand, you need to [add them as external tools](configuring-third-party-tools.html#local-ext-tools).  For more information about how to work with external tools, refer to  the [External tools](configuring-third-party-tools.html) topic.

In the majority of cases, these tools support two types of commands: standard and meta. Standard commands are `SELECT`, `CREATE`, `UPDATE`, and other ordinary SQL commands. Meta-commands use special syntax that is specific for every tool. For example, in SQLite, except for ordinary SQL statements, you can use dot-commands. These dot-commands are used to change the output format of queries or to execute certain prepackaged query statements. When you issue the dot-command, `sqlite3` uses its own interpretation of the command and runs it on a database.

Other tools have different meta-commands. For example, `sqlplus` has `DESCRIBE`; `psql` has backslash directives like `\dD`; in `sqlcmd`, you can use `:r Script.sql` to load a script file. These commands are not standard SQL commands that your database would easily understand. They need to be translated. CLI tools do this translation.

GoLand supports syntax highlighting for meta-commands but not the translation logic. It means that you can open an SQL script with meta-commands in the editor, but you need an external tool to run the script. By default, meta-commands are highlighted in green.

sqlite3:

![sqlite3 dot-commands in the IDE](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_dot_commands_in_ide.png)

psql:

![psql backlash commands in the IDE](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_backlash_commands_in_ide.png)

## Running CLI tools

In this topic, we use `sqlite3` and `psql` as examples. You can create similar configurations for other tools.

For this tutorial, we will use the `sqlite.db` database file for `sqlite3` and the `PostgreSQL` database running locally for `psql`. And we will use the following scripts in the SQL files:

sqlite3:

`script_sqlite3.sql`

```SQL
.databases
.schema main.*
.mode list
.separator ", "
.width 12 -6
.tables
select * from address;
```

psql:

`script_psql.sql`

```SQL
\conninfo
\dt
\d public.address
\pset border 2
\timing on
SELECT * FROM public.address;
```

To run the script, you need to create a configuration for a third-party tool. In our case, `sqlite3` or `psql`. This configuration will pass contextual information from your project to the tool as command-line arguments and display the output in the Run tool window.

Procedure: Step 1. Create an external tool configuration

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) and navigate to `Tools | External Tools`.

2. Click ![the Add button](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg) Add and specify the following settings:

sqlite3:

* Name: the name of the tool that will be displayed in the GoLand interface. For example, `sqlite3` .

* Group: the name of the group to which the tool belongs. You can select an existing group or type the name of a new group.

* Description: a meaningful description of the tool. For example, `Command-line tool for SQLite` .

* Program: the path to the application executable file. For example, `~/files/sqlite/sqlite3` .

* Arguments: the arguments passed to the executable file, as you would specify them on the command line. > **Note:** > Use spaces to separate individual arguments. Use double and single quotes for arguments and paths that contain spaces. Use a backslash to escape double quotes that are part of the argument or path. For example, `sqlite.db ".read '$FilePath$'"` .

* Working directory: the path to the current working directory from which the tool is executed. For example, you can point this field to a folder with the database file (`~/files/sqlite`).

![sqlite3 external tool configuration](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_sqlite_3_external_tool_configuration.png)

In this case, `sqlite3` will be run with `sqlite.db ".read '$FilePath$'"`  arguments.

psql:

* Name: the name of the tool that will be displayed in the GoLand interface. For example, `psql`.

* Group: the name of the group to which the tool belongs. You can select an existing group or type the name of a new group.

* Description: a meaningful description of the tool. For example, `Command-line tool for PostgreSQL` .

* Program: the path to the application executable file. For example, `/Library/PostgreSQL/bin/psql`.

* Arguments: the arguments passed to the executable file, as you would specify them on the command line. > **Note:** > Use spaces to separate individual arguments. Use double and single quotes for arguments and paths that contain spaces. Use a backslash to escape double quotes that are part of the argument or path. For example, `-h localhost -p 54333 -U guest -d guest -f "$FilePath$"`.

* Working directory: the path to the current working directory from which the tool is executed. For example, `/Library/PostgreSQL/bin`.

![psql external tool configuration](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_psql_external_tool_configuration.png)

In this case,  `psql` will be run with `-h localhost -p 54333 -U guest -d guest -f "$FilePath$"` arguments.

You can use macros that can refer to the project name, the current file path, and so on. Clicking ![the Insert Macros icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.general.inlineAddHover.svg) Insert Macros… opens the Macros dialog that lists all available macros and their values.

3. Click OK to add the tool and then apply the changes.

Procedure: Step 2. Run the created configuration

> **Note:**
> The code editor highlights the schema and table names in our examples because the files are not attached to a data source within the IDE. Without a data source, GoLand cannot resolve references to database objects.

* Double-click the script file to open it in the editor.

Press  `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `Ctrl+Shift+P` (VSCode), `F1` (VSCode (macOS)), start typing `External Tools` , then select the action from the list.    Press `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `Ctrl+Shift+P` (VSCode), `F1` (VSCode (macOS)) to open the Search Everywhere popup, start typing `External Tools` and select it from the list.

sqlite3:

In the External Tools popup window, select `sqlite3` .

![Run sqlite3 from the Search Everywhere](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_run_sqlite_3_from_search_everywhere.png)

psql:

In the External Tools popup window, select  `psql`.

![Run psql from the Search Everywhere](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_run_psql_from_search_everywhere.png)

* Open the  Project tool window  by clicking ![Files tool window icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.toolwindows.project.svg) Project on the main window toolbar. Alternatively, press `Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+Shift+E` (VSCode), `⌘ ⇧ E` (VSCode (macOS)).

sqlite3:

Right-click the `sqlite3_demo.sql`  file and select  `External Tools | sqlite3`   from the context menu.

![Run sqlite3 from the context menu](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_run_sqlite_3_from_the_context_menu.png)

psql:

Right-click the  `psql_demo.sql` file and select   `External Tools | pgsql`  from the context menu.

![Run psql from the context menu](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_run_psql_from_the_context_menu.png)

* In the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS))), select Keymap.

sqlite3:

Find the `sqlite3`  action under the External Tools node and assign a shortcut for it by selecting Add Keyboard Shortcut from the context menu. Use the shortcut to run the tool.

![Run sqlite3 by using a mapped shortcut](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_run_sqlite_3_by_using_a_mapped_shortcut.png)

psql:

Find the  `psql` action under the External Tools node and assign a shortcut for it by selecting Add Keyboard Shortcut from the context menu. Use the shortcut to run the tool.

![Run psql by using a mapped shortcut](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_run_psql_by_using_a_mapped_shortcut.png)

GoLand displays the output in the Run tool window.

sqlite3:

![sqlite3 output in the IDE](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_sqlite_3_output_in_ide.png)

psql:

![psql output in the IDE](https://resources.jetbrains.com/help/img/idea/2026.3/db_db_cli_tools_psql_output_in_ide.png)

