---
title: Access and manage saved queries
description: Learn how to work with query data objects in the Databricks UI.
canonical_url: https://docs.databricks.com/aws/en/sql/user/queries/
---

# Access and manage saved queries

This article outlines how to use the Databricks UI to access and manage queries.

## View queries

You can view queries using the following methods:

* Click ![Workspace Icon](https://docs.databricks.com/aws/en/images/icons/workspace-icon.png) **Workspace** in the sidebar. Queries are viewable, by default, in the **Home** folder. Users can organize queries into folders in the workspace browser along with other Databricks objects.
* Click ![Queries Icon](https://docs.databricks.com/aws/en/images/icons/queries-icon.png) **Queries** in the sidebar. Objects in the **Queries** windows are sorted in reverse chronological order by default. You can reorder the list by clicking the **Created at** column heading. Type into the **Filter queries** text box to filter by Name, Tag, or Owner.

## Organize queries into folders in the workspace browser

You can organize queries into folders in the [workspace browser](https://docs.databricks.com/aws/en/workspace/workspace-browser.md) and other Databricks objects. See [Workspace browser](https://docs.databricks.com/aws/en/workspace/workspace-browser.md).

## <a id="transfer-ownership" />Transfer ownership of a query

You must be a workspace admin to transfer ownership of a query. Service principals and groups cannot be assigned ownership of a query. You can also transfer ownership using the [Permissions API](https://docs.databricks.com/api/workspace/permissions).

1. As a workspace admin, log in to your Databricks workspace.

2. In the sidebar, click **Queries**.

3. Click a query.

4. Click the **Share** button at the top right to open the **Sharing** dialog.

5. Click on the gear icon at the top right and click **Assign new owner**.

   ![Assign new owner](https://docs.databricks.com/aws/en/images/sql/security/assign-new-owner.png)

6. Select the user to assign ownership to.

7. Click **Confirm**.

## <a id="share" />Configure query permissions

Workspace admins and the query creator are automatically granted permissions to control which users can manage and run queries. You must have at least CAN MANAGE permission on a query to share queries.

Queries support two types of sharing settings:

* **Run as viewer**: The viewer's credential is used to run the query. The viewer must also have at least CAN USE permissions on the warehouse. In the legacy SQL editor, users can only be granted the CAN EDIT permission when the sharing setting is set to **Run as viewer**.
* **Run as owner**: In the new SQL editor, the owner's credential is used for legacy alerts and Lakeflow Jobs. The viewer's credential is always used to run the query. In the legacy SQL editor, the owner's credential is used to run the query.

For more information on query permission levels, see [Query ACLs](https://docs.databricks.com/aws/en/security/auth/access-control/index.md#query).

1. In the sidebar, click **Queries**.

2. Click a query.

3. Click the ![Share Button](https://docs.databricks.com/aws/en/images/sql/share-button.png) button at the top right to open the **Sharing** dialog.

   ![Manage query permissions](https://docs.databricks.com/aws/en/images/sql/manage-permissions.png)

4. Follow the steps based on the permission type you want to grant:

5. Search for and select the groups and users, and assign the permission level.

6. Click **Add**.

7. In the **Sharing settings > Credentials** field at the bottom, select either **Run as viewer** or **Run as owner**.

You can also copy the link to the query in the Sharing dialog.

## Admin access to all queries

A Databricks workspace admin user has view access to all queries in the workspace. When the **All Queries** tab is selected, a workspace admin can view and delete any queries. However, a workspace admin can't edit a query when sharing setting credentials are set to **Run as owner**.

To view all queries:

1. Click ![Queries Icon](https://docs.databricks.com/aws/en/images/icons/queries-icon.png) **Queries** in the sidebar.
2. Click the **All queries** tab near the top of the screen.

## Creating queries in other environments

You can create queries without using the Databricks UI using the Rest API, a JDBC/ODBC connector, or a partner tool.

See [SQL connectors, libraries, drivers, APIs, and tools](https://docs.databricks.com/aws/en/dev-tools/sql-drivers-tools.md) to run SQL commands and browse database objects in Databricks.

You can also create a query with the [Databricks Terraform provider](https://docs.databricks.com/aws/en/dev-tools/terraform/index.md) and [databricks\_sql\_query](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_query).

See [Technology partners](https://docs.databricks.com/aws/en/integrations/index.md) to learn about partner tools you can use through Partner Connect.
