Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Trabalhar com o histórico de alterações
O histórico de alterações do BigQuery permite rastrear o histórico de alterações em uma tabela do BigQuery. Você pode usar as
funções
do GoogleSQL para ver tipos específicos de alterações feitas durante um período específico. Dessa forma,
é possível processar alterações incrementais feitas em uma tabela. Entender quais alterações foram feitas em uma tabela pode
ajudar você a realizar tarefas como manter uma réplica de tabela fora do
BigQuery e evitar cópias caras.
Permissões necessárias
Para ver o histórico de alterações em uma tabela, é necessário ter a permissão bigquery.tables.getData nela. Os seguintes papéis predefinidos do Identity and Access Management (IAM)
incluem essa permissão:
roles/bigquery.dataViewer
roles/bigquery.dataEditor
roles/bigquery.dataOwner
roles/bigquery.admin
Se uma tabela tiver ou teve
políticas de acesso no nível da linha, somente um
administrador poderá acessar os dados históricos da tabela. A permissão bigquery.rowAccessPolicies.overrideTimeTravelRestrictions é necessária na tabela e está incluída no papel predefinido do IAM roles/bigquery.admin.
Se uma tabela tiver segurança no nível da coluna, só será possível ver o histórico de alterações nas colunas a que você tem acesso.
Funções do histórico de alterações
É possível usar as seguintes funções para entender o histórico de alterações de uma tabela:
APPENDS:
retorna todas as linhas anexadas a uma tabela para um determinado período.
As seguintes operações adicionam linhas ao histórico de alterações APPENDS:
CHANGES:
retorna todas as linhas que foram alteradas em uma tabela para um determinado período. Para usar
a função CHANGES em uma tabela, você precisa definir a
opção enable_change_history da tabela
como TRUE.
As seguintes operações adicionam linhas ao histórico de alterações CHANGES:
Chamar funções do histórico de alterações
gera custos de computação do BigQuery.
As funções APPENDS e CHANGES exigem o processamento de todos os dados gravados na tabela dentro do período especificado. Esse processamento se aplica a todas as gravações, incluindo operações de adição e mutação.
Definir a opção enable_change_history de uma tabela como FALSE não reduz os dados processados pelo APPENDS.
Quando você define
a opção enable_change_history
em uma tabela como TRUE para usar a função CHANGES,
o BigQuery armazena metadados de alteração de tabela. Esses metadados armazenados
geram custos de armazenamento
e custos de computação adicionais do BigQuery.
O valor faturado depende do número e do tipo de alterações feitas na tabela,
e costuma ser pequeno. Tabelas com muitas operações de mudança, especialmente
exclusões grandes, têm mais chances de incorrer em custos perceptíveis.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-03 UTC."],[[["\u003cp\u003eBigQuery change history allows tracking of modifications to BigQuery tables, enabling users to identify specific changes within a given timeframe.\u003c/p\u003e\n"],["\u003cp\u003eAccessing change history requires the \u003ccode\u003ebigquery.tables.getData\u003c/code\u003e permission, included in roles like \u003ccode\u003eroles/bigquery.dataViewer\u003c/code\u003e, \u003ccode\u003eroles/bigquery.dataEditor\u003c/code\u003e, \u003ccode\u003eroles/bigquery.dataOwner\u003c/code\u003e, and \u003ccode\u003eroles/bigquery.admin\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAPPENDS\u003c/code\u003e function returns all rows appended to a table within a specified time range, while the \u003ccode\u003eCHANGES\u003c/code\u003e function, which requires enabling the \u003ccode\u003eenable_change_history\u003c/code\u003e option, returns all changed rows within a given range.\u003c/p\u003e\n"],["\u003cp\u003eUtilizing change history functions incurs BigQuery compute costs, as they must process all data written to the table during the designated time period, and setting \u003ccode\u003eenable_change_history\u003c/code\u003e to \u003ccode\u003eTRUE\u003c/code\u003e adds storage and compute costs.\u003c/p\u003e\n"],["\u003cp\u003eThis is currently a pre-GA feature and it is available "as is", therefore the support may be limited, and any questions or feedback about it should be directed to bq-change-history-feedback@google.com.\u003c/p\u003e\n"]]],[],null,["# Work with change history\n========================\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n| **Note:** For support during the preview, contact [bq-change-history-feedback@google.com](mailto:bq-change-history-feedback@google.com).\n\nBigQuery change history lets you track the history of\nchanges to a BigQuery table. You can use GoogleSQL\n[functions](/bigquery/docs/reference/standard-sql/table-functions-built-in)\nto see particular types of changes made during a specified time range, so\nthat you can process incremental changes made to a table. Understanding what\nchanges have been made to a table can help you do things like incrementally\nmaintain a table replica outside of BigQuery while avoiding\ncostly copies.\n\nRequired permissions\n--------------------\n\nTo view the change history on a table, you need the `bigquery.tables.getData`\npermission on that table. The following predefined Identity and Access Management (IAM)\nroles include this permission:\n\n- `roles/bigquery.dataViewer`\n- `roles/bigquery.dataEditor`\n- `roles/bigquery.dataOwner`\n- `roles/bigquery.admin`\n\nIf a table has, or has had,\n[row-level access policies](/bigquery/docs/row-level-security-intro), then only\na table administrator can access historical data for the table. The\n`bigquery.rowAccessPolicies.overrideTimeTravelRestrictions` permission is\nrequired on the table and is included in the predefined `roles/bigquery.admin`\nIAM role.\n\nIf a table has column-level security, you can only view the\nchange history on the columns that you have access to.\n\nChange history functions\n------------------------\n\nYou can use the following functions to understand a table's change history:\n\n- [`APPENDS`](/bigquery/docs/reference/standard-sql/time-series-functions#appends):\n returns all rows appended to a table for given time range.\n\n The following operations add rows to the `APPENDS` change history:\n - [`CREATE TABLE` DDL statement](/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement)\n - [`INSERT` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#insert_statement)\n - [Data appended as part of a `MERGE` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)\n - [Loading data](/bigquery/docs/loading-data) into BigQuery\n - [Streaming ingestion](/bigquery/docs/write-api)\n- [`CHANGES`](/bigquery/docs/reference/standard-sql/time-series-functions#changes):\n returns all rows that have changed in a table for a given time range. To use\n the `CHANGES` function on a table, you must set the table's\n [`enable_change_history` option](/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list)\n to `TRUE`.\n\n The following operations add rows to the `CHANGES` change history:\n - [`CREATE TABLE` DDL statement](/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement)\n - [`INSERT` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#insert_statement)\n - [Data appended or changed as part of a `MERGE` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)\n - [`UPDATE` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#update_statement)\n - [`DELETE` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#delete_statement)\n - [Loading data](/bigquery/docs/loading-data) into BigQuery\n - [Streaming ingestion](/bigquery/docs/write-api)\n - [`TRUNCATE TABLE` DML statement](/bigquery/docs/reference/standard-sql/dml-syntax#truncate_table_statement)\n - [Jobs](/bigquery/docs/reference/rest/v2/Job) configured with a `writeDisposition` of `WRITE_TRUNCATE`\n - Individual [table partition deletions](/bigquery/docs/managing-partitioned-tables#delete_a_partition)\n\nPricing and costs\n-----------------\n\nCalling change history functions\nincurs [BigQuery compute costs](/bigquery/pricing#analysis_pricing_models).\nBoth the `APPENDS` and `CHANGES` functions require processing all data written\nto the table within the specified time range. This processing applies to all\nwrites, including both append and mutation operations.\nSetting a table's [`enable_change_history` option](/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list) to `FALSE` does not reduce the data processed by `APPENDS`.\n\nWhen you set the\n[`enable_change_history` option](/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list)\non a table to `TRUE` in order to use the `CHANGES` function,\nBigQuery stores table change metadata. This stored metadata\nincurs additional [BigQuery storage costs](/bigquery/pricing#storage)\nand [BigQuery compute costs](/bigquery/pricing#analysis_pricing_models).\nThe amount billed depends on the number and type of changes made to the table,\nand is typically small. Tables that have many change operations, especially\nlarge deletions, are the most likely to incur noticeable costs."]]