Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Crea e gestisci viste materializzate continue
Questo documento descrive come creare ed eseguire operazioni su una vista materializzata continua in Bigtable. Prima di leggere questo documento, consulta la panoramica in Viste materializzate continue.
Puoi creare una vista materializzata continua utilizzando Google Cloud CLI, l'editor di query Bigtable Studio nella console Google Cloud o le librerie client Bigtable per Java e Go.
Prima di iniziare
Se prevedi di utilizzare gcloud CLI, segui questi passaggi.
Per inizializzare gcloud CLI, esegui questo comando:
gcloudinit
Ruoli obbligatori
Per ottenere le autorizzazioni necessarie per creare e gestire viste materializzate continue, chiedi all'amministratore di concederti il ruolo Bigtable Admin (roles/bigtable.admin) sull'istanza.
In caso contrario, chiedi le seguenti autorizzazioni a livello di istanza, a seconda dell'operazione che vuoi eseguire:
Crea: bigtable.materializedViews.create
Aggiorna: bigtable.materializedViews.update
Elimina: bigtable.materializedViews.delete
Elenco: bigtable.materializedViews.list
Per creare una vista materializzata continua, devi disporre anche almeno
dell'autorizzazione bigtable.tables.readRows sulla tabella di origine.
Prima di creare una vista materializzata continua, segui questi passaggi:
(Facoltativo) Come best practice, attiva la
scalabilità automatica per i cluster nella tua istanza per
assicurarti che possano essere scalati verticalmente se necessario mentre Bigtable
elabora e sincronizza la vista materializzata continua e per gestire
qualsiasi utilizzo dello spazio di archiviazione aggiuntivo.
Identifica una tabella Bigtable per la quale disponi dell'autorizzazione di lettura da utilizzare come origine per la vista materializzata continua.
Dopo aver creato una vista materializzata continua, potrebbero essere necessari alcuni minuti prima che
diventi attiva e interrogabile. Puoi esaminare le
metriche
della visualizzazione per monitorarne l'avanzamento.
Console
Apri l'elenco delle istanze Bigtable nella console Google Cloud .
VIEW: un identificatore univoco per la vista materializzata continua. Utilizzi questo ID come ID tabella quando
esegui query sulla vista materializzata continua.
INSTANCE: l'identificatore dell'istanza in cui creare
la vista materializzata continua. Deve essere la stessa istanza della tabella di origine.
QUERY: un'istruzione SQL valida che definisce la
vista materializzata continua.
(Facoltativo) Per abilitare la protezione da eliminazione per la vista materializzata continua, aggiungi
il comando con quanto segue:
--deletion-protection=DELETION_PROTECTION
Sostituisci DELETION_PROTECTION con true o
false.
Aggiornare una vista materializzata continua
Puoi aggiornare la protezione da eliminazione per una vista materializzata continua. Non puoi
aggiornare la query SQL che definisce una vista materializzata continua. Se devi
modificare la query, devi eliminare la vista materializzata continua e poi
crearne una nuova che includa le modifiche.
Console
Non puoi aggiornare una vista materializzata continua nella console.
Utilizza invece gcloud CLI.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 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)"]]