[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-06-11(UTC)"],[],[],null,["# Create and manage saved queries\n\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to create and manage saved queries. When you write\nSQL scripts in Spanner Studio,\nyou can save and manage those SQL scripts. For more information, see [Saved queries overview](/spanner/docs/saved-queries)\n.\n\nThe saved queries capability is available only in the Google Cloud console.\n\nRequired roles\n--------------\n\nTo get the permissions that you need to use saved queries, ask your\nadministrator to grant you the following Identity and Access Management (IAM) roles on\nthe project:\n\n- To create, edit, and delete saved queries: [Studio Query User](/iam/docs/roles-permissions/databasesconsole) (`roles/databasesconsole.studioQueryUser`)\n- To manage all saved queries in a project, including access to the **Saved queries** page: [Studio Query Admin](/iam/docs/roles-permissions/databasesconsole) (`roles/databasesconsole.studioQueryAdmin`)\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\nThese predefined roles contain the permissions required to use saved\nqueries. To learn more about required permissions, see [Required permissions](#required-permissions).\n\n### Required permissions\n\nTo create, view, modify, and delete saved queries, you need the following IAM\npermissions at the project level:\n\n| **Note:** Having access to saved queries doesn't automatically mean that you have permissions to run the query.\n\nYou can also get these permissions using [custom roles](/iam/docs/creating-custom-roles)\nor other [predefined roles](/iam/docs/roles-overview#predefined).\n\nThe [Studio Query User](/iam/docs/roles-permissions/databasesconsole)\n(`roles/databasesconsole.studioQueryUser`)\nrole provides create, view, and write saved queries access. This role meets\nthe needs of most users.\n\nGrant the [Studio Query Admin](/iam/docs/roles-permissions/databasesconsole)\n(`roles/databasesconsole.studioQueryAdmin`)\nrole only to administrators. For more information about\nSpanner IAM, see [IAM overview](/spanner/docs/iam).\n\nCreate a saved query\n--------------------\n\nTo create a saved query, follow these steps:\n\n1. Go to the Spanner **Instances** page in the Google Cloud console. \n [Instances](https://console.cloud.google.com/spanner/instances)\n2. Select the instance in which you want to create a saved query.\n3. Select the database in which you want to create a saved query.\n4. In the navigation menu, click **Spanner Studio**.\n5. On the **Spanner Studio** page, click add **New tab** or use the empty editor tab.\n6. In the query editor, enter a SQL query.\n7. Click **Save**.\n8. In the **Save query** dialog, enter a name for the saved query.\n9. Click **Save**.\n\nOpen and run a saved query\n--------------------------\n\nTo open a saved query as a new query, follow these steps:\n\n1. In the **Explorer** pane on the **Spanner Studio** page, navigate to the **Queries** section.\n2. Click a saved query to open it in a new editor tab. Optionally, you can click more_vert **View actions** next to a saved query. Then, click **Open query** to open it in a new editor tab.\n3. Click **Run**.\n\nUpdate a saved query\n--------------------\n\nTo update an existing saved query, follow these steps:\n\n1. In the **Explorer** pane on the **Spanner Studio** page, navigate to the **Queries** section.\n2. Click a saved query to open it in a new editor tab. Optionally, you can click more_vert **View actions** next to a saved query. Then, click **Open query** to open it in a new editor tab.\n3. Modify the query.\n4. To save the modified query, click **Save**.\n\nView and manage a list of all saved queries\n-------------------------------------------\n\nTo view a list of all saved queries in your project, follow these steps:\n\n1. Go to the Spanner **Instances** page in the Google Cloud console. \n [Instances](https://console.cloud.google.com/spanner/instances)\n2. Select any instance. Because a saved query is a child of a project, as long as you have the required role, you can view all saved queries in the project from any instance or database.\n\n\u003c!-- --\u003e\n\n3. Select any database.\n4. In the **Explorer** pane on the **Spanner Studio** page, navigate to the **Queries** section.\n5. Click more_vert **View actions** next to a saved query. Then, click **Manage queries** .\n\n The **Saved queries** page opens. This page lists all the saved\n queries in this project, including saved queries for other\n Google Cloud products.\n\nYou can search, filter, view, and delete queries on the **Saved queries**\npage. You can't edit an existing query on the **Saved queries** page.\n\nDelete a saved query\n--------------------\n\nYou can delete a saved query from the **Spanner Studio**\npage or on the **Saved queries** page in the Google Cloud console.\n\n1. In the Explorer pane on the **Spanner Studio** page, navigate to the Queries section.\n2. Click more_vert **View actions** next to the saved query that you want to delete. Then click **Delete query** to delete the saved query.\n3. In the **Delete query** dialog, click **Delete**.\n\nYou can also delete a saved query on the **Saved queries** page. To delete a saved query on\nthe **Saved queries** page, follow these steps:\n\n1. Navigate to the [**Saved queries**](#view-and-manage) page.\n2. Click more_vert **View actions** next to the saved query that you want to delete.\n3. Click **Delete query** to delete the saved query.\n4. In the **Delete query** dialog, click **Delete**.\n\nWhat's next\n-----------\n\n- Learn about [saved queries](/spanner/docs/saved-queries)."]]