Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Créer et gérer des vues matérialisées continues
Ce document explique comment créer et effectuer des opérations sur une vue matérialisée continue dans Bigtable. Avant de lire ce document, consultez la présentation des vues matérialisées continues.
Vous pouvez créer une vue matérialisée continue à l'aide de Google Cloud CLI, de l'éditeur de requêtes Bigtable Studio dans la console Google Cloud ou des bibliothèques clientes Bigtable pour Java et Go.
Avant de commencer
Si vous prévoyez d'utiliser la gcloud CLI, procédez comme suit.
Pour initialiser la gcloud CLI, exécutez la commande suivante :
gcloudinit
Rôles requis
Pour obtenir les autorisations nécessaires pour créer et gérer des vues matérialisées continues, demandez à votre administrateur de vous accorder le rôle Administrateur Bigtable (roles/bigtable.admin) sur l'instance.
Sinon, demandez les autorisations suivantes au niveau de l'instance, en fonction de l'opération que vous souhaitez effectuer :
Créer : bigtable.materializedViews.create
Mise à jour : bigtable.materializedViews.update
Supprimer : bigtable.materializedViews.delete
Liste : bigtable.materializedViews.list
Pour créer une vue matérialisée continue, vous devez également disposer au minimum de l'autorisation bigtable.tables.readRows sur la table source.
Avant de créer une vue matérialisée continue, procédez comme suit :
Facultatif : Par mesure de précaution, activez l'autoscaling pour les clusters de votre instance. Vous vous assurerez ainsi qu'ils peuvent évoluer si nécessaire pendant que Bigtable traite et synchronise la vue matérialisée continue, et pour gérer toute utilisation de l'espace de stockage supplémentaire.
Identifiez une table Bigtable que vous êtes autorisé à lire et qui servira de source pour la vue matérialisée continue.
Préparez la requête SQL qui définit votre vue matérialisée continue. Pour connaître les exigences concernant les requêtes, consultez Requêtes de vues matérialisées continues.
Une fois que vous avez créé une vue matérialisée continue, il peut s'écouler quelques minutes avant qu'elle ne devienne active et puisse être interrogée. Vous pouvez consulter les métriques de la vue pour suivre sa progression.
Console
Ouvrez la liste des instances Bigtable dans la console Google Cloud .
VIEW : identifiant unique de la vue matérialisée continue. Vous devez utiliser cet ID comme ID de table lorsque vous interrogez la vue matérialisée continue.
INSTANCE : identifiant de l'instance dans laquelle créer la vue matérialisée continue. Doit être la même instance que la table source.
QUERY : instruction SQL valide qui définit la vue matérialisée continue.
Facultatif : pour activer la protection contre la suppression de la vue matérialisée continue, ajoutez la commande suivante :
--deletion-protection=DELETION_PROTECTION
Remplacez DELETION_PROTECTION par true ou false.
Mettre à jour une vue matérialisée continue
Vous pouvez modifier la protection contre la suppression pour une vue matérialisée continue. Vous ne pouvez pas mettre à jour la requête SQL qui définit une vue matérialisée continue. Si vous devez modifier la requête, vous devez supprimer la vue matérialisée continue, puis en créer une qui inclut vos modifications.
Console
Vous ne pouvez pas mettre à jour une vue matérialisée continue dans la console.
Utilisez plutôt gcloud CLI.
VIEW : identifiant unique de la vue matérialisée continue que vous souhaitez mettre à jour
INSTANCE : identifiant de l'instance contenant la vue matérialisée continue
DELETION_PROTECTION : true ou false
Supprimer une vue matérialisée continue
Vous pouvez supprimer une vue matérialisée continue pour laquelle la protection contre la suppression n'est pas activée. Cette opération est irréversible.
Console
Ouvrez la liste des instances Bigtable dans la console Google Cloud .
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]