[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-21。"],[[["\u003cp\u003eThis guide outlines the process for updating a table snapshot's metadata, including its description, expiration date, and access policies, within Google BigQuery.\u003c/p\u003e\n"],["\u003cp\u003eUpdating metadata requires the \u003ccode\u003ebigquery.tables.update\u003c/code\u003e permission, which is granted by roles such as \u003ccode\u003ebigquery.dataEditor\u003c/code\u003e, \u003ccode\u003ebigquery.dataOwner\u003c/code\u003e, or \u003ccode\u003ebigquery.admin\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTable snapshot data itself cannot be directly updated; instead, users must restore the snapshot to a standard table to modify the data.\u003c/p\u003e\n"],["\u003cp\u003eChanges to the table snapshot's description or expiration can be done through the Google Cloud console, the \u003ccode\u003ebq update\u003c/code\u003e command, or the \u003ccode\u003etables.patch\u003c/code\u003e API method.\u003c/p\u003e\n"],["\u003cp\u003eAccess control updates, enabling a user to view the snapshot data, are done through the console's share option, the \u003ccode\u003ebq add-iam-policy-binding\u003c/code\u003e command, or the \u003ccode\u003etables.setIamPolicy\u003c/code\u003e API.\u003c/p\u003e\n"]]],[],null,["# Update table snapshot metadata\n==============================\n\nThis document describes how to update the description, expiration date, or\naccess policy for a table\nsnapshot by using the Google Cloud console, the [`bq update`](/bigquery/docs/reference/bq-cli-reference#bq_update)\ncommand, or the\n[`tables.patch`](/bigquery/docs/reference/rest/v2/tables/patch) API.\nIt is intended for users who are familiar with\n[tables](/bigquery/docs/tables-intro) and\n[table snapshots](/bigquery/docs/table-snapshots-intro) in BigQuery.\n\nPermissions and roles\n---------------------\n\nThis section describes the\n[Identity and Access Management (IAM) permissions](/bigquery/docs/access-control#bq-permissions)\nthat you need to update the metadata for a table snapshot, and the\n[predefined IAM roles](/bigquery/docs/access-control#bigquery)\nthat grant those permissions.\n\n### Permissions\n\nTo update a table snapshot's metadata, you need the following permission:\n\n### Roles\n\nThe predefined BigQuery roles that provide the required\npermission are as follows:\n\nLimitations\n-----------\n\nYou can update a table snapshot's metadata, but you can't update its data\nbecause table snapshot data is read only. To update a table snapshot's data,\nyou must first restore the table snapshot to a standard table, and then update\nthe standard table's data. For more information, see\n[Restoring table snapshots](/bigquery/docs/table-snapshots-restore).\n\nUpdate a table snapshot's metadata\n----------------------------------\n\nYou can change a table snapshot's description, expiration, and access policies\nin the same way as you change a standard table's metadata. Some examples are\nprovided in the following sections.\n\n### Update the description\n\nYou can change the description for a table snapshot by using one of the\nfollowing options: \n\n### Console\n\n1. In the Google Cloud console, go to the **BigQuery** page.\n\n [Go to BigQuery](https://console.cloud.google.com/bigquery)\n2. In the **Explorer** pane, expand the project and dataset nodes of the\n table snapshot you want to update.\n\n3. Click the name of the table snapshot.\n\n4. In the snapshot pane that appears, click the **Details** tab, and\n then click **Edit Details**.\n\n5. In the **Description** field, add or update the description for the\n table snapshot.\n\n6. Click **Save**.\n\n### bq\n\nEnter the following command in the Cloud Shell:\n\n[Go to Cloud Shell](https://console.cloud.google.com/bigquery?cloudshell=true) \n\n```bash\nbq update \\\n--description=\"\u003cvar translate=\"no\"\u003eDESCRIPTION\u003c/var\u003e\" \\\nPROJECT_ID:DATASET_NAME.SNAPSHOT_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eDESCRIPTION\u003c/var\u003e: text describing the snapshot. For example, `Snapshot after table schema change X.`.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID of the project that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eDATASET_NAME\u003c/var\u003e: the name of the dataset that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eSNAPSHOT_NAME\u003c/var\u003e: the name of the snapshot.\n\n\u003cbr /\u003e\n\n### API\n\nCall the\n[`tables.patch`](/bigquery/docs/reference/rest/v2/tables/patch)\nmethod with the following parameters:\n\nPrefer the `tables.patch` method over the `tables.update` method because the\n`tables.update` method replaces the entire `Table` resource.\n\n### Update the expiration\n\nYou can change the expiration of a table snapshot by using one of the\nfollowing options: \n\n### Console\n\n1. In the Google Cloud console, go to the **BigQuery** page.\n\n [Go to BigQuery](https://console.cloud.google.com/bigquery)\n2. In the **Explorer** pane, expand the project and dataset nodes of the\n table snapshot you want to update.\n\n3. Click the name of the table snapshot.\n\n4. In the snapshot pane that appears, click the **Details** tab, and\n then click **Edit Details**.\n\n5. In the **Expiration time** field, enter the new expiration time for the\n table snapshot.\n\n6. Click **Save**.\n\n### bq\n\nEnter the following command in the Cloud Shell:\n\n[Go to Cloud Shell](https://console.cloud.google.com/bigquery?cloudshell=true) \n\n```bash\nbq update \\\n--expiration=EXPIRATION_TIME \\\nPROJECT_ID:DATASET_NAME.SNAPSHOT_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eEXPIRATION_TIME\u003c/var\u003e: the number of seconds from the current time to the expiration time.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID of the project that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eDATASET_NAME\u003c/var\u003e: the name of the dataset that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eSNAPSHOT_NAME\u003c/var\u003e: the name of the snapshot.\n\n\u003cbr /\u003e\n\n### API\n\nCall the\n[`tables.patch`](/bigquery/docs/reference/rest/v2/tables/patch)\nmethod with the following parameters:\n\nPrefer the `tables.patch` method over the `tables.update` method because the\n`tables.update` method replaces the entire `Table` resource.\n\n### Update access\n\nYou can give a user access to view the data in a table snapshot by using\none of the following options: \n\n### Console\n\n1. In the Google Cloud console, go to the **BigQuery** page.\n\n [Go to BigQuery](https://console.cloud.google.com/bigquery)\n2. In the **Explorer** pane, expand the project and dataset nodes of the\n table snapshot you want to update.\n\n3. Click the name of the table snapshot.\n\n4. In the snapshot pane that appears, click **Share** , then click **Add\n principal**.\n\n5. In the **Add principals** pane that appears, enter the identifier of the\n [principal](/iam/docs/principals-overview) you want to\n give access to the table snapshot.\n\n6. In the **Select a role** dropdown, choose **BigQuery** , then\n **BigQuery Data Viewer**.\n\n7. Click **Save**.\n\n### bq\n\nEnter the following command in the Cloud Shell:\n\n[Go to Cloud Shell](https://console.cloud.google.com/bigquery?cloudshell=true) \n\n```bash\nbq add-iam-policy-binding \\\n --member=\"user:\u003cvar translate=\"no\"\u003ePRINCIPAL\u003c/var\u003e\" \\\n --role=\"roles/bigquery.dataViewer\" \\\n PROJECT_ID:DATASET_NAME.SNAPSHOT_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePRINCIPAL\u003c/var\u003e: the [principal](/iam/docs/principals-overview) you want to give access to the table snapshot.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID of the project that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eDATASET_NAME\u003c/var\u003e: the name of the dataset that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eSNAPSHOT_NAME\u003c/var\u003e: the name of the snapshot.\n\n\u003cbr /\u003e\n\n### API\n\nCall the\n[`tables.setIamPolicy`](/bigquery/docs/reference/rest/v2/tables/setIamPolicy)\nmethod with the following parameters:\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID of the project that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eDATASET_NAME\u003c/var\u003e: the name of the dataset that contains the snapshot.\n- \u003cvar translate=\"no\"\u003eSNAPSHOT_NAME\u003c/var\u003e: the name of the snapshot.\n- \u003cvar translate=\"no\"\u003ePRINCIPAL\u003c/var\u003e: the [principal](/iam/docs/overview#concepts_related_identity) you want to give access to the table snapshot.\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- [List the table snapshots in a dataset](/bigquery/docs/table-snapshots-list).\n- [View the metadata for a table snapshot](/bigquery/docs/table-snapshots-metadata).\n- [Delete a table snapshot](/bigquery/docs/table-snapshots-delete)."]]