SQL Console

[Edit this page](https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/cloud/features/03_sql_console_features/01_sql-console.md)

SQL console is the fastest and easiest way to explore and query your databases in ClickHouse Cloud. You can use the SQL console to:

- Connect to your ClickHouse Cloud Services
- View, filter, and sort table data
- Execute queries and visualize result data in just a few clicks
- Share queries with team members and collaborate more effectively.

### Exploring tables[​](#exploring-tables "Direct link to Exploring tables")

### Viewing table list and schema info[​](#viewing-table-list-and-schema-info "Direct link to Viewing table list and schema info")

An overview of tables contained in your ClickHouse instance can be found in the left sidebar area. Use the database selector at the top of the left bar to view the tables in a specific database

Tables in the list can also be expanded to view columns and types

### Exploring table data[​](#exploring-table-data "Direct link to Exploring table data")

Click on a table in the list to open it in a new tab. In the Table View, data can be easily viewed, selected, and copied. Note that structure and formatting are preserved when copy-pasting to spreadsheet applications such as Microsoft Excel and Google Sheets. You can flip between pages of table data (paginated in 30-row increments) using the navigation in the footer.

### Inspecting cell data[​](#inspecting-cell-data "Direct link to Inspecting cell data")

The Cell Inspector tool can be used to view large amounts of data contained within a single cell. To open it, right-click on a cell and select 'Inspect Cell'. The contents of the cell inspector can be copied by clicking the copy icon in the top right corner of the inspector contents.

## Filtering and sorting tables[​](#filtering-and-sorting-tables "Direct link to Filtering and sorting tables")

### Sorting a table[​](#sorting-a-table "Direct link to Sorting a table")

To sort a table in the SQL console, open a table and select the 'Sort' button in the toolbar. This button will open a menu that will allow you to configure your sort. You can choose a column by which you want to sort and configure the ordering of the sort (ascending or descending). Select 'Apply' or press Enter to sort your table

The SQL console also allows you to add multiple sorts to a table. Click the 'Sort' button again to add another sort.

Note

Sorts are applied in the order that they appear in the sort pane (top to bottom). To remove a sort, simply click the 'x' button next to the sort.

### Filtering a table[​](#filtering-a-table "Direct link to Filtering a table")

To filter a table in the SQL console, open a table and select the 'Filter' button. Just like sorting, this button will open a menu that will allow you to configure your filter. You can choose a column by which to filter and select the necessary criteria. The SQL console intelligently displays filter options that correspond to the type of data contained in the column.

When you're happy with your filter, you can select 'Apply' to filter your data. You can also add additional filters as shown below.

Similar to the sort functionality, click the 'x' button next to a filter to remove it.

### Filtering and sorting together[​](#filtering-and-sorting-together "Direct link to Filtering and sorting together")

The SQL console allows you to filter and sort a table at the same time. To do this, add all desired filters and sorts using the steps described above and click the 'Apply' button.

### Creating a query from filters and sorts[​](#creating-a-query-from-filters-and-sorts "Direct link to Creating a query from filters and sorts")

The SQL console can convert your sorts and filters directly into queries with one click. Simply select the 'Create Query' button from the toolbar with the sort and filter parameters of your choosing. After clicking 'Create query', a new query tab will open pre-populated with the SQL command corresponding to the data contained in your table view.

Note

Filters and sorts aren't mandatory when using the 'Create Query' feature.

You can learn more about querying in the SQL console by reading the (link) query documentation.

## Creating and running a query[​](#creating-and-running-a-query "Direct link to Creating and running a query")

### Creating a query[​](#creating-a-query "Direct link to Creating a query")

There are two ways to create a new query in the SQL console.

- Click the '+' button in the tab bar
- Select the 'New Query' button from the left sidebar query list

### Running a query[​](#running-a-query "Direct link to Running a query")

To run a query, type your SQL command or commands into the SQL Editor and click the 'Run' button or use the shortcut `cmd / ctrl + enter`. To write and run multiple commands sequentially, make sure to add a semicolon after each command.

Query Execution Options
By default, clicking the run button will run all commands contained in the SQL Editor. The SQL console supports two other query execution options:

- Run selected commands
- Run command at the cursor

To run selected commands, highlight the desired command or sequence of commands and click the 'Run' button (or use the `cmd / ctrl + enter` shortcut). You can also select 'Run selected' from the SQL Editor context menu (opened by right-clicking anywhere within the editor) when a selection is present.

Running the command at the current cursor position can be achieved in two ways:

- Select 'At Cursor' from the extended run options menu (or use the corresponding `cmd / ctrl + shift + enter` keyboard shortcut

- Selecting 'Run at cursor' from the SQL Editor context menu

Note

The command present at the cursor position will flash yellow on execution.

### Canceling a query[​](#canceling-a-query "Direct link to Canceling a query")

While a query is running, the 'Run' button in the Query Editor toolbar will be replaced with a 'Cancel' button. Simply click this button or press `Esc` to cancel the query. Note: Any results that have already been returned will persist after cancellation.

### Saving a query[​](#saving-a-query "Direct link to Saving a query")

Saving queries allows you to easily find them later and share them with your teammates. The SQL console also allows you to organize your queries into folders.

To save a query, simply click the "Save" button immediately next to the "Run" button in the toolbar. Input the desired name and click "Save Query".

Note

Using the shortcut `cmd / ctrl` + s will also save any work in the current query tab.

Alternatively, you can simultaneously name and save a query by clicking on "Untitled Query" in the toolbar, adjusting the name, and hitting Enter:

### Query sharing[​](#query-sharing "Direct link to Query sharing")

The SQL console allows you to easily share queries with your team members. The SQL console supports four levels of access that can be adjusted both globally and on a per-user basis:

- Owner (can adjust sharing options)
- Write access
- Read-only access
- No access

After saving a query, click the "Share" button in the toolbar. A modal with sharing options will appear:

To adjust query access for all organization members with access to the service, simply adjust the access level selector in the top line:

After applying the above, the query can now be viewed (and executed) by all team members with access to the SQL console for the service.

To adjust query access for specific members, select the desired team member from the "Add a team member" selector:

After selecting a team member, a new line item should appear with an access level selector:

### Accessing shared queries[​](#accessing-shared-queries "Direct link to Accessing shared queries")

If a query has been shared with you, it will be displayed in the "Queries" tab of the SQL console left sidebar:

### Linking to a query (permalinks)[​](#linking-to-a-query-permalinks "Direct link to Linking to a query (permalinks)")

Saved queries are also permalinked, meaning that you can send and receive links to shared queries and open them directly.