bqquery\--use_legacy_sql=false\--destination_table='my_table$20160501'\--append_table=true\'SELECT * FROM my_dataset.another_table'
수집 시간으로 파티션 나누기를 사용하면 이 기법으로 데이터가 원래 생성된 시간에 해당하는 이전 데이터를 파티션에 로드할 수 있습니다.
이 기법을 사용하여 시간대를 조정할 수도 있습니다. 기본적으로 수집 시간 파티션은 UTC 시간을 따릅니다. 파티션 시간을 특정 시간대와 일치시키려면 파티션 데코레이터를 사용하여 UTC 수집 시간을 상쇄하면 됩니다. 예를 들어 태평양 표준시(PST)를 사용하는 경우에는 2016년 5월 1일 PST에 생성된 데이터를 해당 파티션 데코레이터 $20160501을 사용하여 해당 날짜의 파티션에 로드할 수 있습니다.
시간 단위 열과 정수 범위로 파티션을 나눈 테이블의 경우 데코레이터에 지정된 파티션 ID가 작성 중인 데이터와 일치해야 합니다. 예를 들어 DATE 열에서 테이블 파티션을 나눈 경우 데코레이터가 해당 열의 값과 일치해야 합니다. 그렇지 않으면 오류가 발생합니다. 그러나 데이터가 단일 파티션에 있음을 미리 알고 있는 경우 파티션 데코레이터를 지정하면 쓰기 성능을 향상시킬 수 있습니다.
앞의 예시에서는 데이터를 파티션에 추가합니다. 파티션의 데이터를 덮어쓰려면 각 명령어에 서로 다른 플래그(bq load --replace=true ... 및 bq query --append_table=false ...)를 포함해야 합니다.
이러한 명령어의 플래그에 대한 자세한 내용은 bq load 및 bq query를 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-02-11(UTC)"],[[["\u003cp\u003eData can be loaded into a specific partition of a table using the \u003ccode\u003ebq load\u003c/code\u003e command with a partition decorator, such as \u003ccode\u003e$20160501\u003c/code\u003e for the May 1, 2016 partition.\u003c/p\u003e\n"],["\u003cp\u003eQuery results can be written to a specific partition by using the \u003ccode\u003ebq query\u003c/code\u003e command and specifying the destination table with a partition decorator, along with appropriate flags.\u003c/p\u003e\n"],["\u003cp\u003ePartition decorators can be used with ingestion-time partitioning to load older data into the correct partition or to adjust for time zone differences, by loading the data into a partition reflecting the correct time.\u003c/p\u003e\n"],["\u003cp\u003eFor time-unit column and integer-range partitioned tables, the partition ID specified in the decorator must align with the data being written to avoid errors, although it can improve write performance.\u003c/p\u003e\n"],["\u003cp\u003eData can be appended or overwritten in a partition by adjusting \u003ccode\u003ebq load\u003c/code\u003e or \u003ccode\u003ebq query\u003c/code\u003e flags.\u003c/p\u003e\n"]]],[],null,["# Load data into partitioned tables\n=================================\n\nThis document describes how to load data into partitioned tables.\n\nWrite data to a specific partition\n----------------------------------\n\nYou can load data to a specific partition by using the\n[`bq load`](/bigquery/docs/reference/bq-cli-reference#bq_load) command with a\npartition decorator. The following example appends data into the `20160501` (May\n1, 2016) partition of an existing table, assuming the table is already\npartitioned by date: \n\n```bash\nbq load --source_format=CSV 'my_dataset.my_table$20160501' data.csv\n```\n\nYou can also write the results of a query to a specific partition: \n\n```bash\nbq query \\\n --use_legacy_sql=false \\\n --destination_table='my_table$20160501' \\\n --append_table=true \\\n 'SELECT * FROM my_dataset.another_table'\n```\n\nWith ingestion-time partitioning, you can use this technique to load older data\ninto the partition that corresponds to the time when the data was originally\ncreated.\n\nYou can also use this technique to adjust for time zones. By default, ingestion-\ntime partitions are based on UTC time. If you want the partition time to match a\nparticular time zone, you can use partition decorators to offset the UTC\ningestion time. For example, if you are on Pacific Standard Time (PST), you can\nload data that was generated on May 1, 2016 23:30 PST into the partition for\nthat date by using the corresponding explicit partition decorator,\n`$2016050123`. If you didn't use this explicit decorator, it would instead load\ninto `$2016050207` (May 2nd 07:00 UTC).\n\nFor time-unit column and integer-range partitioned tables, the partition ID\nspecified in the decorator must match the data being written. For example, if\nthe table is partitioned on a `DATE` column, the decorator must match the value\nin that column. Otherwise, an error occurs. However, if you know beforehand that\nyour data is in a single partition, specifying the partition decorator can\nimprove write performance.\n\nThe preceding example appends data to a partition. To overwrite data in a\npartition instead, you must include different flags for each command, namely\n`bq load --replace=true ...` and `bq query --append_table=false ...`.\nFor more information about the flags in these commands, see [`bq load`](/bigquery/docs/reference/bq-cli-reference#bq_load)\nand [`bq query`](/bigquery/docs/reference/bq-cli-reference#bq_query).\n\nFor more information on loading data, see\n[Introduction to loading data into BigQuery](/bigquery/docs/loading-data).\n\nStream data into partitioned tables\n-----------------------------------\n\nFor information about streaming data into a partitioned table with the\nBigQuery Storage Write API, see\n[Stream into partitioned tables](/bigquery/docs/write-api#stream_into_partitioned_tables).\n\nWhat's next\n-----------\n\nTo learn more about working with partitioned tables, see:\n\n- [Creating partitioned tables](/bigquery/docs/creating-partitioned-tables)\n- [Managing partitioned tables](/bigquery/docs/managing-partitioned-tables)\n- [Querying partitioned tables](/bigquery/docs/querying-partitioned-tables)"]]