
## Save and share queries

URL: https://docs.atlan.com/product/capabilities/insights/how-tos/save-and-share-queries

> Save queries to collections for reuse, scheduling, and sharing. Organize queries with descriptions and certificates, assign terms, and control sharing permissions by granting viewer or editor access to other users and groups.

Save your queries to collections for easy access and reuse across your organization. Share collections with specific users and groups, control access permissions, and organize queries with descriptions, [certificates](https://docs.atlan.com/llms/catalog/discovery/add-certificates/llms.txt), and [glossary terms](https://docs.atlan.com/llms/governance/glossary/what-is-a-glossary/llms.txt).

:::info **Did you know?** 
 You can only save queries through a _collection_. You can share collections with others, to share your queries.

:::

## Save a query

To save a query:

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

2. At the top right of the query, click the **Save** button.
3. In the resulting _Save query_ dialog, enter the following details:
 1. For _Query name_, enter a name for the query.
 2. (Optional) For _Description_, add a description for the query.
 3. For _Collection_, you can either:
 - If you have access to existing collections, click the **Choose collection** dropdown to select an existing collection.
 - If you do not have any existing collections, click the **Create Collection** button. In the _Create collection_ dialog, enter the following details:
 1. For _Name_, enter a name for the collection.
 2. (Optional) To the left of the name, click the image icon to choose an icon for the collection.
 3. (Optional) For _Description_, describe the collection.
 4. (Optional) For _Share_, select other users or groups that can access the collection. (See below for more details.)
 5. At the bottom of the _Create Collection_ dialog, click **Create**.
 4. (Optional) For _Certificate_, click the **No certification** dropdown to assign a [certificate](https://docs.atlan.com/llms/catalog/discovery/add-certificates/llms.txt) to the query.
 5. (Optional) For _Linked terms_, click the **Select terms** dropdown to assign a [term](https://docs.atlan.com/llms/governance/glossary/what-is-a-glossary/llms.txt) to the query.
 6. At the bottom of the dialog:
 - To only save your query, click **Save**.
 - To save and share your query, click **Save and share**.
 1. In the _Query saved_ dialog, enter the following details:
 1. For _Add users or groups_, select other users or groups that can access the saved query.
 1. (Optional) To the right of the user or group, click the **Editor** dropdown to change the sharing permissions:
 - _Viewer_ allows users to view and run all queries in the collection, but not edit them.
 - _Editor_ allows users to view, run, and edit all queries in the collection.
 2. Click **Invite** to invite the users or groups.
 2. (Optional) Click **Copy Link** to copy the link for the saved query to share with others in your team.
 3. (Optional) Click the **Slack** or **Teams** button to share directly on [Slack](https://docs.atlan.com/llms/governance/integrations/integrate-slack/llms.txt) or [Microsoft Teams](https://docs.atlan.com/llms/governance/integrations/integrate-microsoft-teams/llms.txt), respectively.
 2. Click **Done** to confirm your selections.

:::info **Did you know?** 
 Atlan currently supports a query length of 2 million characters for saved queries.
:::

## Share a query collection

A collection helps you organize saved queries in Atlan. A collection could represent a topic, department, or team with similar saved queries under one roof. Within each collection, you can have a folder that contains multiple saves queries of a similar type.

To share a collection of queries:

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

2. In the upper left, click the papers-in-a-box icon.
3. Under the icon, click the name of the selected query collection.
4. From the resulting list of collections, hover over the collection you want to share.
5. Click the 3-dot icon to the right of the collection name and choose **Edit collection**.
6. In the _Edit collection_ dialog, under _Share_:
 1. Search for users or groups with whom to share the collection.
 2. (Optional) To the right of the user or group, click the **Can edit** dropdown to change the sharing permissions:
 - _Can edit_ allows users to view, run, and edit all queries in the collection.
 - _Can view_ allows users to view and run all queries in the collection, but not edit them.
 3. Repeat these steps for each user or group with whom you want to share the collection.
7. At the bottom of the _Edit collection_ dialog, click **Update**.

:::info **Did you know?** 
 Users with only _Can view_ permissions will still be able to change the interactive part of [interactive queries](https://docs.atlan.com/llms/catalog/insights/make-a-query-interactive/llms.txt).
:::

## Move a saved query

To move a saved query to another query collection:

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

2. In the upper left, click the papers-in-a-box icon.
3. Under the icon, click the name of the selected query collection.
4. From the resulting list of collections, hover over the collection from which you want to move a query.
5. Click the 3-dot icon to the right of the saved query name, and then click **Move to**.
6. In the _Move to_ dialog, select the query collection to which you want to move your saved query.
7. Click **Move** to complete moving the saved query.

To duplicate, rename, edit, or delete your saved query, click the 3-dot icon to the right of the saved query name and select the relevant option.

:::info **Did you know?** 
 If you add a Slack channel to the [_Query output share channels_ field in your Slack integration](https://docs.atlan.com/llms/governance/integrations/integrate-slack/llms.txt), you will be able to share your saved query and query results directly on that Slack channel. Atlan will deliver the query results as a CSV file on the same Slack thread.
:::

## View query sidebar

Once you've [saved a query](#save-a-query), you can access the query sidebar to view additional context for your saved queries.

To open the query sidebar for a saved query:

1. In the left _Explorer_ panel in _Insights_, hover over a saved query and click the **Open query sidebar** icon.
2. From the saved query sidebar in the right, you can:
 - View details about your saved query in _Overview_, including the actual query. (Optional) You can add more details to your saved query: 
 - Click the star button to [star the query](https://docs.atlan.com/llms/catalog/discovery/star-assets/llms.txt) for quick access.
 - For _Description_, add a [description](https://docs.atlan.com/llms/catalog/discovery/add-descriptions/llms.txt) to your saved query.
 - Click **+Add README** to add a [README](https://docs.atlan.com/llms/governance/integrations/llms.txt) to your saved query and provide more context.
 - For _Collection_, click the collection name to view the query collection.
 - Copy the SQL query or expand the query view to fullscreen.
 - For _Terms_, add a [term](https://docs.atlan.com/llms/governance/glossary/what-is-a-glossary/llms.txt) to [link to your saved query](https://docs.atlan.com/llms/governance/glossary/link-terms-to-assets/llms.txt).
 - For _Owners_, update the [owner](https://docs.atlan.com/llms/catalog/discovery/add-owners/llms.txt) of the saved query or add more owners.
 - For _Tags_, [attach a tag](https://docs.atlan.com/llms/governance/tags/attach-a-tag/llms.txt) to your saved query.
 - For _Certificate_, update the [certification status](https://docs.atlan.com/llms/catalog/discovery/add-certificates/llms.txt) of your saved query.
 - Click the **Relations** tab to view queried assets. 
 - (Optional) Select a related asset to open the asset sidebar. From the asset sidebar, click the **Queries** tab to view the saved query auto-linked to the asset.
 - Click the **Activity** tab to view the [activity log](https://docs.atlan.com/llms/catalog/discovery/faq/llms.txt) for the saved query.
 - Click the **Schedules** tab to view [associated schedules](https://docs.atlan.com/llms/catalog/insights/schedule-a-query/llms.txt) for the saved query, if any.
 - Click the **Resources** tab to view any linked [resources](https://docs.atlan.com/llms/catalog/discovery/add-a-resource/llms.txt).
 - Click the **Requests** tab to view any [requests](https://docs.atlan.com/llms/catalog/requests/what-are-requests/llms.txt) on the saved query.
 - Click the **Properties** tab to view query properties.
 - Click the **Slack** or **Teams** tab to view [Slack](https://docs.atlan.com/llms/governance/integrations/slack-integration/llms.txt) or [Teams](https://docs.atlan.com/llms/governance/integrations/microsoft-teams-integration/llms.txt) messages pertaining to the query.

## Link saved queries

Once you have saved a query, the saved query will be auto-linked to all the assets queried or referenced in the SQL query. Linked queries are displayed in the [asset profile](https://docs.atlan.com/llms/catalog/discovery/what-are-asset-profiles/llms.txt) and [sidebar](https://docs.atlan.com/llms/catalog/discovery/what-are-asset-profiles/llms.txt).

You might want to link it to other assets, too. This can help you provide additional context on the assets and quickly find the saved query. For such assets, you can link the saved query as a [resource](https://docs.atlan.com/llms/catalog/discovery/add-a-resource/llms.txt).

To link a saved query to an asset:

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

2. In the upper left, click the papers-in-a-box icon.
3. Under the icon, click the name of a query collection.
4. From the resulting list of collections, select a collection and then select the saved query you want to link as a [resource](https://docs.atlan.com/llms/catalog/discovery/add-a-resource/llms.txt).
5. To copy the link for a saved query, you can either:

 - Click the 3-dot icon to the right of the saved query name and then click **Copy link**.

 - In the top right of the query editor, click the 3-dot icon and then click **Share**. From the _Share_ menu, click **Copy link**.
6. Click on all assets to navigate to your assets.
 * If you are using the **Old UI (Classic)**, from the left menu, click **Assets**.
7. From the _Assets_ page, select an asset to open the asset profile.
8. In the README footer, scroll down to the **Resources** section and click **\+ Add resource**.
 * If you are using the **Old UI (Classic)**, from the asset sidebar on the right, click the **Resources** tab and then click **\+ Add resource**.
9. In the _Add Resource_ dialog, enter the following details:
 1. For _Link_, paste the saved query link you copied in Data Exploration.
 2. For _Title_, add a title for your saved query.
 3. Click **Add** to add the saved query as a [resource](https://docs.atlan.com/llms/catalog/discovery/add-a-resource/llms.txt) to the asset.

:::info **Did you know?** 
 Any user in Atlan will be able to preview saved queries for auto-linked or manually linked assets from the asset sidebar - unless there are [access policies](https://docs.atlan.com/llms/governance/access-control/what-are-purposes/llms.txt) prohibiting them.

:::

---
