Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Criar e gerenciar visualizações materializadas contínuas
Neste documento, descrevemos como criar e realizar operações em uma visualização materializada contínua no Bigtable. Antes de ler este documento, confira a visão geral em Visualizações materializadas contínuas.
É possível criar uma visualização materializada contínua usando a Google Cloud CLI, o
editor de consultas do Bigtable Studio no console Google Cloud ou as
bibliotecas de cliente do Bigtable para Java e Go.
Antes de começar
Siga estas etapas se você planeja usar a CLI gcloud.
Para inicializar a gcloud CLI, execute o seguinte comando:
gcloudinit
Funções exigidas
Para receber as permissões necessárias para criar e gerenciar visualizações materializadas
contínuas, peça ao administrador para conceder a você o papel de
Administrador do Bigtable (roles/bigtable.admin) na instância.
Caso contrário, peça as seguintes permissões no nível da instância, dependendo da operação que você quer realizar:
Criar: bigtable.materializedViews.create
Atualizar: bigtable.materializedViews.update
Excluir: bigtable.materializedViews.delete
Lista: bigtable.materializedViews.list
Para criar uma visualização materializada contínua, você também precisa ter pelo menos a permissão bigtable.tables.readRows na tabela de origem.
Antes de criar uma visualização materializada contínua, faça o seguinte:
Opcional: como prática recomendada, ative o escalonamento automático para clusters na sua instância. Assim, eles poderão ser escalonar verticalmente, se necessário, enquanto o Bigtable processa e sincroniza a visualização materializada contínua e lida com qualquer uso de armazenamento adicional.
Identifique uma tabela do Bigtable que você tenha permissão para ler e usar como origem da visualização materializada contínua.
Depois de criar uma visualização materializada contínua, ela pode levar alguns minutos para
ficar ativa e pronta para consultas. Consulte as métricas da visualização para monitorar o progresso.
Console
Abra a lista de instâncias do Bigtable no console Google Cloud .
VIEW: um identificador exclusivo da
visualização materializada contínua. Use esse ID como o ID da tabela ao consultar a visualização materializada contínua.
INSTANCE: o identificador da instância em que a visualização materializada contínua será criada. Precisa ser a mesma instância da tabela de origem.
QUERY: uma instrução SQL válida que define a
visualização materializada contínua.
Opcional: para ativar a proteção contra exclusão da visualização materializada contínua, adicione o seguinte ao
comando:
--deletion-protection=DELETION_PROTECTION
Substitua DELETION_PROTECTION por true ou false.
Atualizar uma visualização materializada contínua
É possível atualizar a proteção contra exclusão de uma visualização materializada contínua. Não é possível
atualizar a consulta SQL que define uma visualização materializada contínua. Se você precisar
modificar a consulta, exclua a visualização materializada contínua e
crie uma nova que inclua suas mudanças.
Console
Não é possível atualizar uma visualização materializada contínua no console.
Em vez disso, use a CLI gcloud.
[[["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-09 UTC."],[],[],null,["Create and manage continuous materialized views\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\nThis document describes how to create and perform operations on a continuous\nmaterialized view in Bigtable. Before you read this document, read the\noverview at [Continuous materialized views](/bigtable/docs/materialized-views).\n\nYou can create a continuous materialized view using the Google Cloud CLI, the\nBigtable Studio query editor in the Google Cloud console, or the\nBigtable client libraries for Java and Go.\n\nBefore you begin\n\nTake the following steps if you plan to use the gcloud CLI.\n\n1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n2. If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n3.\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n | **Note:** You can run the gcloud CLI in the Google Cloud console without installing the Google Cloud CLI. To run the gcloud CLI in the Google Cloud console, [use\n | Cloud Shell](https://console.cloud.google.com/?cloudshell=true).\n\n\u003cbr /\u003e\n\n| **Note:** If the gcloud CLI returns a `Method not found` message, run the [`gcloud auth login`](/sdk/gcloud/reference/auth/login) command again.\n\nRequired roles\n\nTo get the permissions that you need to create and manage continuous\nmaterialized views, ask your administrator to grant you the\nBigtable Admin (`roles/bigtable.admin`) role on the instance.\nOtherwise, ask for the following permissions at the instance level, depending on\nthe operation that you want to perform:\n\n- Create: `bigtable.materializedViews.create`\n- Update: `bigtable.materializedViews.update`\n- Delete: `bigtable.materializedViews.delete`\n- List: `bigtable.materializedViews.list`\n\nTo create a continuous materialized view, you must also have at least\n`bigtable.tables.readRows` permission on the source table.\n\nTo see all available roles and permissions, see\n[Bigtable access control with IAM](/bigtable/docs/access-control).\n\nCreate a continuous materialized view\n\nBefore you create a continuous materialized view, do the following:\n\n- Optional: As a best practice, enable [autoscaling](/bigtable/docs/autoscaling) for clusters in your instance to make sure they can scale up if necessary while Bigtable processes and synchronizes the continuous materialized view and to handle any additional [storage usage](/bigtable/docs/continuous%0Amaterialized-views#storage).\n- Identify a Bigtable table that you have permission to read to use as the source for the continuous materialized view.\n- Prepare the SQL query that defines your continuous materialized view. For query requirements, see [Continuous materialized view\n queries](/bigtable/docs/continuous-materialized-view-queries).\n\nAfter you create a continuous materialized view, it might take a few minutes to\nbecome active and queryable. You can look at\n[metrics](/bigtable/docs/continuous-materialized-views#metrics)\nfor the view to monitor its progress. \n\nConsole\n\n1.\n Open the list of Bigtable instances in the Google Cloud console.\n\n\n [Open the instance list](https://console.cloud.google.com/bigtable/instances)\n2. Select an instance.\n\n3. In the navigation pane, click **Bigtable Studio**.\n\n4. Open a new tab by clicking add and\n then choosing **Editor**.\n\n 1. When the query editor appears, write your query. If the query is\n valid SQL, a **Valid** message is displayed.\n\n 2. Optional: To format your statement in SQL style, click **Format**.\n\n 3. Click **Run** . The results of your query appear in the **Results** table.\n\n 4. When you're satisfied with the query, click **Save** and then choose\n **Materialized view**.\n\n For more information about using the query editor, see [Manage your\n data using Bigtable\n Studio](/bigtable/docs/manage-data-using-console).\n\ngcloud\n\nTo create a continuous materialized view, use the\n[`gcloud beta bigtable materialized-views create`](/sdk/gcloud/reference/beta/bigtable/materialized-views/create)\ncommand: \n\n gcloud beta bigtable materialized-views create \u003cvar translate=\"no\"\u003eVIEW\u003c/var\u003e \\\n --instance=\u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e --query=\u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eVIEW\u003c/var\u003e: a unique identifier for the continuous materialized view. You use this ID as the table ID when querying the continuous materialized view.\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e: the identifier of the instance to create the continuous materialized view in. Must be the same instance as the source table.\n- \u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e: a valid SQL statement that defines the continuous materialized view.\n\nOptional: to enable deletion protection for the continuous materialized view, append the\ncommand with the following: \n\n --deletion-protection=\u003cvar translate=\"no\"\u003eDELETION_PROTECTION\u003c/var\u003e\n\nReplace \u003cvar translate=\"no\"\u003eDELETION_PROTECTION\u003c/var\u003e with either `true` or\n`false`.\n\nUpdate a continuous materialized view\n\nYou can update deletion protection for a continuous materialized view. You can't\nupdate the SQL query that defines a continuous materialized view; if you need to\nmodify the query, you must delete the continuous materialized view and then\ncreate a new one that includes your changes. \n\nConsole\n\nYou can't update a continuous materialized view in the console.\nUse the gcloud CLI instead.\n\ngcloud\n\nTo enable or disable deletion protection for a continuous materialized view, use\nthe [`gcloud beta bigtable materialized-views update command`](/sdk/gcloud/reference/beta/bigtable/materialized-views/update) command. \n\n gcloud beta bigtable materialized-views update \u003cvar translate=\"no\"\u003eVIEW\u003c/var\u003e \\\n ---instance=\u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e --deletion-protection=\u003cvar translate=\"no\"\u003eDELETION_PROTECTION\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eVIEW\u003c/var\u003e: the unique identifier for the continuous materialized view that you want to update\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e: the identifier of the instance containing the continuous materialized view\n- \u003cvar translate=\"no\"\u003eDELETION_PROTECTION\u003c/var\u003e: either `true` or `false`\n\nDelete a continuous materialized view\n\nYou can delete a continuous materialized view that doesn't have deletion protection\nenabled. You can't undo this operation. \n\nConsole\n\n1.\n Open the list of Bigtable instances in the Google Cloud console.\n\n\n [Open the instance list](https://console.cloud.google.com/bigtable/instances)\n2. Select an instance from the list.\n\n3. In the navigation pane, click **Bigtable Studio**.\n\n4. Expand **Materialized views**.\n\n5. Next to the view that you want to delete, click the\n more_vert action menu,\n and then click **Delete**.\n\ngcloud\n\nTo delete a continuous materialized view, use the\n[`gcloud beta bigtable materialized-views delete`](/sdk/gcloud/reference/beta/bigtable/materialized-views/delete)\ncommand: \n\n gcloud beta bigtable materialized-views delete \u003cvar translate=\"no\"\u003eVIEW\u003c/var\u003e \\\n --instance=\u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eVIEW\u003c/var\u003e: the unique identifier for the continuous materialized view that you want to delete\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e: the identifier of the instance containing the continuous materialized view\n\nGet a list of continuous materialized views\n\nYou can see a list of continuous materialized views for an instance. \n\nConsole\n\n1.\n Open the list of Bigtable instances in the Google Cloud console.\n\n\n [Open the instance list](https://console.cloud.google.com/bigtable/instances)\n2. Select an instance from the list.\n\n3. In the navigation pane, click **Bigtable Studio.** A list of\n continuous materialized views is displayed.\n\n4. Optional: The first 10 views in the instance are listed. To see 10 more,\n click **Show more**.\n\ngcloud\n\nTo list all continuous materialized views for an instance, use the\n[`gcloud bigtable materialized-views list`](/sdk/gcloud/reference/beta/bigtable/materialized-views/list) command. \n\n gcloud bigtable materialized-views list --instance=\u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e\n\nReplace \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e with the instance ID.\n\nWhat's next\n\n- [Continuous materialized view queries](/bigtable/docs/continuous-materialized-view-queries)\n- [Tables and views](/bigtable/docs/tables-and-views)"]]