membuat snapshot tabel BigQuery

Menunjukkan cara membuat tabel snapshot dari tabel BigQuery terkelola.

Contoh kode

Python

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Python di Panduan memulai BigQuery menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi BigQuery Python API.

Untuk melakukan autentikasi ke BigQuery, siapkan Kredensial Default Aplikasi. Untuk informasi selengkapnya, lihat Menyiapkan autentikasi untuk library klien.

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))

Langkah berikutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat Google Cloud browser contoh.