This page describes how to save and share queries. Queries that are saved or shared contain only the query itself, which means that:
-
A shared query provides the query text only. You still need to have appropriate access to query the data. One advantage of saving only the query text is that you can share a query that is incomplete, even if it isn't a valid query, and use it as a template that other users can complete or customize.
-
The only query option retained by a saved query is the "SQL Version", which governs whether the query uses legacy SQL or standard SQL.
Saving queries
To save a query in BigQuery:
-
Go to the BigQuery web UI.
Go to the BigQuery web UI -
Click the Compose query button.
-
Enter a BigQuery SQL query in the New Query text area. For example, you can use the example from the Web UI Quickstart.
SELECT weight_pounds, state, year, gestation_weeks FROM publicdata:samples.natality ORDER BY weight_pounds DESC LIMIT 10; -
Click the Save Query button to open the Save Query dialog box.
-
In the Save Query dialog box, enter a name for your saved query; leave the Visibility set to Private (Visible only to you); then click OK.

-
To view your saved query, ensure that Query History is selected in the left navigation and click on Saved Queries in the Queries section.

Modifying queries
If you have write permissions on a query, you can modify it:
-
Load the query into the query editing window by clicking the Edit Query button.

-
Modify the query.
-
Click the Save Query button to open the Save Query dialog box.
-
In the Save Query dialog box, leave the name unchanged and click OK.
Sharing queries
To share a query, set its visibility to Project or Public when you save the query.
-
Project visibility makes the query available to other project members.
- Project members with OWNER/WRITER permissions have read-write access.
- Project members with READ permissions have read access.
-
Public visibility makes the query viewable, but not editable, to anyone with the link.
When you share a query, consider including a comment that describes the query as shown in the example that follows.
Sharing queries with project members
To share a query with another member of your project:
-
Go to the BigQuery web UI.
Go to the BigQuery web UI -
Click the Compose query button.
-
Enter a BigQuery SQL query in the New Query text area. For example, you can use the example from the Web UI Quickstart.
# Find highest birth weights SELECT weight_pounds, state, year, gestation_weeks FROM publicdata:samples.natality ORDER BY weight_pounds DESC LIMIT 10; -
Click the Save Query button to open the Save Query dialog box.
-
In the Save Query dialog box, enter a name for your saved query; set the Visibility set to Project (Project members can view and edit); then click OK.

-
To view your saved query, ensure that Query History is selected in the left navigation and click on Project Queries in the Queries section.

-
Click on the name of your saved project query to expand the window.

-
Click on the Share Link button to access the shareable link and copy the link to the clipboard.

Alternatively, you can access the link via the link icon above the New Query text area.

-
Share the link with another member of your team.
Sharing queries with the public
To share a query with anyone:
-
Go to the BigQuery web UI.
Go to the BigQuery web UI -
Click the Compose query button.
-
Enter a BigQuery SQL query in the New Query text area. For example, you can use the example from the Web UI Quickstart.
# Find highest birth weights SELECT weight_pounds, state, year, gestation_weeks FROM publicdata:samples.natality ORDER BY weight_pounds DESC LIMIT 10; -
Click the Save Query button to open the Save Query dialog box.
-
In the Save Query dialog box, enter a name for your saved query; set the Visibility set to Public (Anyone with the link can view, but not edit); then click OK.

-
To view your saved query, ensure that Query History is selected in the left navigation and click on Saved Queries in the Queries section.

-
Click on the name of your saved public query to expand the window.

-
Click on the Share Link button to access the shareable link and copy the link to the clipboard.

Alternatively, you can access the link via the link icon above the New Query text area.

-
Share the link with another member of your team.