Snapshot einer BigQuery-Tabelle erstellen

Hier wird gezeigt, wie Sie eine Snapshot-Tabelle aus einer verwalteten BigQuery-Tabelle erstellen.

Codebeispiel

Python

Bevor Sie dieses Beispiel anwenden, folgen Sie den Schritten zur Einrichtung von Python in der BigQuery-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Angaben finden Sie in der Referenzdokumentation zur BigQuery Python API.

Richten Sie zur Authentifizierung bei BigQuery die Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für Clientbibliotheken einrichten.

from google.cloud import bigquery

# TODO(developer): Set table_id to the ID of the table to create.
source_table_id = "your-project.your_dataset.your_table_name"
snapshot_table_id = "your-project.your_dataset.snapshot_table_name"

# Construct a BigQuery client object.
client = bigquery.Client()
copy_config = bigquery.CopyJobConfig()
copy_config.operation_type = bigquery.OperationType.SNAPSHOT

copy_job = client.copy_table(
    sources=source_table_id,
    destination=snapshot_table_id,
    job_config=copy_config,
)
copy_job.result()

print("Created table snapshot {}".format(snapshot_table_id))

Nächste Schritte

Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.