A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/bigquery/docs/saving-sharing-queries below:

Create saved queries | BigQuery

Stay organized with collections Save and categorize content based on your preferences.

Create saved queries

When you write SQL in the query editor, you can save your query and share your query with others. Saved queries are BigQuery Studio code assets powered by Dataform.

For more information on deleting saved queries and managing saved query history, see Manage saved queries.

Required permissions

Set the appropriate permissions to create, edit, or view saved queries.

All users with the Dataform Admin (roles/dataform.admin) role have owner access to all saved queries created in the project.

For more information about BigQuery Identity and Access Management (IAM), see Access control with IAM.

Permissions to create saved queries

To create and run saved queries, you need the following IAM permissions:

You can get these permissions from the following IAM roles:

Permissions to edit saved queries

To edit and run saved queries, you need the following IAM roles:

Permissions to view saved queries

To view and run saved queries, you need the following IAM roles:

Set the default region for code assets

If this is the first time you are creating a code asset, you should set the default region for code assets. You can't change the region for a code asset after it is created.

Note: If you create a saved query and choose a different default region than the one you have been using for code assets, for example choosing us-west1 when you have been using us-central1, then that query and all code assets you create afterwards use that new region by default. Existing code assets continue to use the region they were assigned when they were created.

All code assets in BigQuery Studio use the same default region. To set the default region for code assets, follow these steps:

  1. Go to the BigQuery page.

    Go to BigQuery

  2. In the Explorer pane, find the project in which you have enabled code assets.

  3. Click more_vert View actions next to the project, and then click Change my default code region.

  4. For Region, select the region that you want to use for code assets.

  5. Click Select.

For a list of regions where is available, see BigQuery Studio locations.

Create saved queries

To create a saved query, follow these steps:

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. Click add_box SQL query.

  3. In the query editor, enter a valid SQL query. For example, you can query a public dataset:

    SELECT
      name,
      SUM(number) AS total
    FROM
      `bigquery-public-data.usa_names.usa_1910_2013`
    GROUP BY
      name
    ORDER BY
      total DESC
    LIMIT
      10;
  4. Click Save > Save query or press Control+S.

  5. In the Save query dialog, type a name for the saved query.

  6. Optional: To change the region used by this saved query and all other code assets in the future, select a new region in Region.

  7. Click Save.

    The first version of the saved query is created.

  8. Optional: After you save the query, use the following toolbar to view query details or the version history, add new comments, or reply to or get a link to an existing comment:

    The Details, Version history, and Comments toolbar features are in Preview. To provide feedback or request support for these features, send an email to bqui-workspace-pod@google.com.

To share a saved query with a user, you first grant that user access to the saved query and add them to an appropriate IAM role. Then you generate a link to the saved query and share that link with the user.

Users that you share a query with only see the most recent version of a query. Autosaved changes that you haven't explicitly saved don't appear in the shared query.

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. In the Explorer pane, expand your project and the Queries folder, and if necessary, the Shared queries folder. Find and click the saved query that you want to grant access to.

  3. Click person_addShare, and then click Manage permissions.

  4. In the Manage permissions pane, click Add user/group.

  5. In the New principals field, enter a principal.

  6. In the Role list, select one of the following roles:

    Note: The principal must also have the BigQuery User (roles/bigquery.user) role to run the saved query.
  7. Optional: To view a complete list of roles and advanced sharing settings, click Advanced sharing.

  8. Click Save.

  9. To return to the saved query info, click Close.

  10. To generate a link to the saved query, click person_addShare, and then click Get link.

    The link is copied to your clipboard.

Open a saved query version as a new query

To open any version of an existing saved query as a new query, follow these steps:

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. In the Explorer pane, expand your project and the Queries folder, and if necessary, the Shared queries folder. Select a saved query.

  3. Click history Version history.

  4. Click more_vert View actions next to a saved query version and then click Open as new query.

Update saved queries

Changes that you make to the text of a saved query are automatically saved two seconds after you stop typing and appear in your Version history as Your changes. Autosaved changes aren't a new version of the query. Your autosaved changes reappear any time you open the query but aren't visible to anyone else unless you explicitly save them as a new version of the query. Autosaved queries are in Preview.

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. In the Explorer pane, expand your project and the Queries folder, and if necessary, the Shared queries folder. Click the name of a saved query to open it.

  3. Modify the query.

  4. To save the modified query, click Save query > Save query or press Control+S (or Command+S on macOS).

    A new version of the query is created.

Upload saved queries

You can upload a local SQL query to use it as a saved query in BigQuery Studio. The uploaded saved query is then also visible in the BigQuery page of the Google Cloud console.

To upload a saved query, follow these steps:

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. In the Explorer pane, expand your project, and then do one of the following:

  3. In the Upload SQL dialog, in the SQL field, click Browse, and then select the query that you want to upload.

  4. Optional: In the SQL name field, edit the name of the query.

  5. In the Region field, select the region where you want to upload your saved query.

  6. Click Upload.

Your saved query appears in the Explorer pane.

Classic saved queries Deprecated: Saved queries, available in BigQuery Studio, will fully replace classic saved queries in the future. The deprecation timeline is being reviewed. For more information, see Deprecation of classic saved queries. To learn how to migrate to saved queries, see Migrate classic saved queries.

Use the following sections to learn how to create and update classic saved queries. For more information on sharing, migrating, and deleting classic saved queries, see Classic saved queries.

Note: If you have not enabled BigQuery Studio, classic saved queries appear in the Saved queries (NUMBER) folder of the Explorer pane instead of the (Classic) Queries folder. Required permissions for classic saved queries

The following IAM permissions are required to create, view, update, and delete classic saved queries:

Note: Users given the dataform.repository.list permission at the project level can see all saved queries created in the project.

For more information on IAM roles in BigQuery, see Predefined roles and permissions.

Create classic saved queries
  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. Click add_box SQL query.

  3. In the query editor, enter a valid SQL query. For example, you can query a public dataset:

    SELECT
      name,
      SUM(number) AS total
    FROM
      `bigquery-public-data.usa_names.usa_1910_2013`
    GROUP BY
      name
    ORDER BY
      total DESC
    LIMIT
      10;
  4. Click Save Query (Classic) > Save query (Classic).

  5. In the Save query dialog, enter a name for your query, and then set Visibility to one of the following options:

  6. Click Save.

You can share classic saved queries that you have given project or public visibility. Project visibility allows principals with the required permissions to view, update, or delete the query. Public visibility allows anyone with the query link to view but not update or delete the query.

You share a classic saved query with other users by generating and sharing a link to the classic saved query.

To run a classic shared query, users must have access to the data that the query accesses. For more information, see Grant access to a dataset.

If you are plan to share a classic saved query, consider including a comment in the query that describes its purpose.

  1. In the Explorer pane, expand your project and the (Classic) Queries folder, and then find the classic saved query you want to share.
  2. Click more_vert View actions next to the query and then click Get link.
  3. Share the link with the users you want to grant access to the query.
Update classic saved queries
  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. In the Explorer pane, expand your project and the (Classic) Queries folder, and if necessary, the Project queries folder.

  3. Click the name of a classic saved query to open it.

  4. Modify the query.

  5. To save the modified query, click Save Query (Classic) > Save query (Classic).

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Saved queries are code assets in BigQuery Studio powered by Dataform, allowing users to save and share SQL queries."],["Creating saved queries requires specific IAM permissions, including `dataform.locations.get`, `dataform.locations.list`, `dataform.repositories.list`, and `dataform.repositories.create`, obtainable through roles like BigQuery Job User, BigQuery Read Session User, or Code Creator."],["Sharing saved queries involves granting users access through roles like Code Owner, Code Editor, or Code Viewer and generating a shareable link, while also requiring the BigQuery User role to run the query."],["Users can upload local SQL queries to use them as saved queries, which become visible in the BigQuery page of the Google Cloud console, ensuring they choose the appropriate region for their query."],["Classic saved queries are deprecated and will be fully replaced by saved queries in BigQuery Studio, requiring specific IAM permissions depending on whether they are private, project-level, or public, and can be shared via a generated link."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4