
## Query data

URL: https://docs.atlan.com/product/capabilities/insights/how-tos/query-data

> Query data in Atlan using SQL or the Visual Query Builder. Write custom SQL queries, use read-based statements, preview results, and schedule queries to run on a schedule.

Query data directly from your connected sources using two flexible approaches: write custom SQL queries using the query editor, or use the Visual Query Builder for a point-and-click interface. All queries execute at the source with access policies applied to results automatically.

:::info **Did you know?** 
 Atlan pushes all queries to the source (no data is stored in Atlan). In addition, Atlan applies access policies to the results before displaying them.

:::

## Write your own SQL

:::warning Who can do this?
 Anyone with the knowledge to write SQL. Any [Atlan user](https://docs.atlan.com/llms/governance/access-control/delegate-administration/llms.txt) with [data access to the asset](https://docs.atlan.com/llms/governance/access-control/data-policy/llms.txt) can query data.

:::

To query an asset with your own SQL:

1. From the left sidebar, click on **all assets** and then click on **Queries**.
 * If you are using the **Old UI (Classic)**, from the left menu of any screen, click **Data Exploration**.

2. Under the _Explorer_ tab, find the asset you want to query:
 1. Use the _Select database_ dropdown to choose another database, if necessary.
 2. Search for the asset by name in the search bar, or browse for it in the tree structure.
3. Hover over the table or view, and click the play icon. This writes and runs a basic preview query.
 - (Optional) Click the open asset sidebar icon to view more details in the asset sidebar.
 - (Optional) Click the eye icon to view a preview of the query results.
 - (Optional) Click the 3-dot icon for more options:
 - Click **Set editor context** to set the same connection, database, and schema name in the query editor as selected in the _Explorer_ tab.
 - Click **Place name in editor** to view the asset name in the query editor.
 - Click **Copy path** to copy the full path of the asset, including database and schema names.
4. Under the _Untitled_ tab on the right, change the sample query or write your own - separate multiple queries with a semicolon `;`. Click the **Run** button in the upper right to test your query as you write it.
 - (Optional) Click the downward arrow next to the _Run_ button to [export query results via email](https://docs.atlan.com/llms/catalog/insights/tips-and-tricks/llms.txt) or [schedule the query](https://docs.atlan.com/llms/catalog/insights/schedule-a-query/llms.txt).
5. (Optional) If you have multiple tabs open in the query editor, right-click a tab to open the tabs menu. You can close a specific tab or all tabs, or duplicate the query.
6. (Optional) From the top right of the query editor, click the 3-dot icon for additional query editor actions or to customize it further:
 - Click or hover over _Duplicate query_ to create a duplicate version of your query.
 - Click or hover over _Open command palette_ to view the actions you can run inside the query editor.
 - Click or hover over _Themes_ and then select your preferred theme for the query editor.
 - Click or hover over _Tab spacing_ to change the tab spacing for your queries.
 - Click or hover over _Font size_ to change the font size for your queries.
 - Click or hover over _Cursor_ to change the cursor position in the query editor.
 - Click or hover over _Autosuggestions_ to turn off autosuggestions for assets in the query editor.

The editor supports all read-based SQL statements, including `JOIN`. The editor will not run any write-based statements. The following SQL statements are not supported:

- `UPDATE`
- `DELETE`
- `CREATE`
- `ALTER`
- `DROP`
- `TRUNCATE`
- `INSERT INTO`

:::info **Did you know?** 
 You can select the context for your query to the left of the _Run_ button. Then you won't need to fully qualify table names with schema and database names.

:::

## Use the Visual Query Builder

:::warning Who can do this?
 Any [Atlan user](https://docs.atlan.com/llms/governance/access-control/delegate-administration/llms.txt) with [data access to the asset](https://docs.atlan.com/llms/governance/access-control/data-policy/llms.txt). No SQL knowledge required!

:::

To query an asset using the Visual Query Builder:

1. From the left sidebar, click on **all assets** and then click on **Queries**.
 * If you are using the **Old UI (Classic)**, from the left menu of any screen, click **Data Exploration**.

2. At the top of the screen, to the right of the _Untitled_ tab, click the **+** button and select **New visual query**.
3. Under _Select from_ choose the table or view you want to query.
4. (Optional) In the column selector to the right, select the column you want to query.
5. Then develop your query:
 - Click the **Run** button to run the query and preview its results.
 - Click the blue circular **+** button to add an action to the query.
 - Repeat these steps until your query is complete.
6. (Optional) If there are any errors in your query, click **Auto fix** for Atlan to recommend a fix. 
7. (Optional) In the query results set, click **Copy** to copy the query results or click **Download** to export them.

:::info **Did you know?** 
 You can learn more about the query builder actions in [this example](https://docs.atlan.com/llms/catalog/insights/what-are-the-query-builder-actions/llms.txt).

:::

---
