Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Metadaten eines Tabellen-Snapshots aktualisieren
In diesem Dokument wird beschrieben, wie Sie die Beschreibung, das Ablaufdatum oder die Zugriffsrichtlinie für einen Tabellen-Snapshot mithilfe der Google Cloud Console, des bq update-Befehls oder der tables.patch API aktualisieren.
Es richtet sich an Nutzer, die mit Tabellen und Tabellen-Snapshots in BigQuery vertraut sind.
Sie können die Metadaten eines Tabellen-Snapshots aktualisieren, jedoch nicht die Daten, da die Daten eines Tabellen-Snapshots schreibgeschützt sind. Wenn Sie die Daten eines Tabellen-Snapshots aktualisieren möchten, müssen Sie zuerst den Tabellen-Snapshot in einer Standardtabelle wiederherstellen und dann die Daten der Standardtabelle aktualisieren. Weitere Informationen finden Sie unter Tabellen-Snapshots wiederherstellen.
Metadaten eines Tabellen-Snapshots aktualisieren
Sie können die Beschreibung, Ablaufzeit und Zugriffsrichtlinien eines Tabellen-Snapshots genauso ändern wie die Metadaten einer Standardtabelle. In den folgenden Abschnitten finden Sie einige Beispiele.
Beschreibung aktualisieren
Sie können die Beschreibung für einen Tabellen-Snapshot mit einer der folgenden Optionen ändern:
Console
Öffnen Sie in der Google Cloud Console die Seite BigQuery.
Maximieren Sie im Bereich Explorer die Projekt- und Dataset-Knoten des Tabellen-Snapshots, den Sie aktualisieren möchten.
Klicken Sie auf den Namen des Tabellen-Snapshots.
Klicken Sie im angezeigten Bereich des Snapshots auf Freigeben und dann auf Hauptkonto hinzufügen.
Geben Sie im angezeigten Bereich Hauptkonten hinzufügen die Kennzeichnung des Hauptkontos ein, dem Sie Zugriff auf den Tabellen-Snapshot gewähren möchten.
Wählen Sie im Drop-down-Menü Rolle auswählen die Option BigQuery und dann BigQuery Data Viewer aus.
Klicken Sie auf Speichern.
bq
Führen Sie dazu in Cloud Shell den folgenden Befehl aus.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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)."]]