BigQuery 테이블의 스냅샷 만들기

관리형 BigQuery 테이블에서 스냅샷 테이블을 만드는 방법을 보여줍니다.

코드 샘플

Python

이 샘플을 사용해 보기 전에 BigQuery 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 BigQuery Python API 참고 문서를 확인하세요.

BigQuery에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 클라이언트 라이브러리의 인증 설정을 참조하세요.

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

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.