Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Atualizar metadados de snapshot da tabela
Veja neste documento como atualizar a descrição, a data de validade ou
a política de acesso de um snapshot
de tabela usando o Console do Google Cloud, o comando
bq update ou a API
tables.patch.
Ele se destina a usuários que já conhecem
tabelas e
snapshots de tabelas no BigQuery.
É possível atualizar os metadados de um snapshot de tabela, mas não os dados porque os dados de snapshot da tabela são somente leitura. Para atualizar os dados de um snapshot da tabela,
restaure o snapshot da tabela para uma tabela padrão e, em seguida, atualize
os dados da tabela padrão. Para mais informações, consulte Como restaurar snapshots de tabelas.
Atualizar metadados do snapshot de uma tabela
É possível alterar a descrição, a validade e as políticas de acesso de um snapshot de tabela da mesma forma que os metadados de uma tabela padrão. Veja alguns exemplos
nas seções a seguir.
Atualizar a descrição
É possível alterar a descrição de um snapshot da tabela usando uma das
seguintes opções:
Console
No Console do Google Cloud, acesse a página BigQuery.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-04-21 UTC."],[[["\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)."]]