Você precisa ter um destes papéis do IAM no projeto Google Cloud que está usando:
roles/alloydb.admin (o papel predefinido do IAM de administrador do AlloyDB)
roles/owner (o papel básico Proprietário do IAM)
roles/editor (o papel básico de editor do IAM)
Se você não tiver nenhum desses papéis, entre em contato com o administrador da organização para solicitar
acesso.
Ativar uma extensão
Em geral, você ativa uma extensão conectando-se a um banco de dados na instância principal de um cluster do AlloyDB e inserindo um comando LOAD ou CREATE EXTENSION.
No entanto, algumas extensões exigem que você defina uma ou mais flags de banco de dados antes de usar o comando LOAD ou CREATE EXTENSION para ativar a extensão. Você define essas flags na instância do AlloyDB em que quer usar a extensão, seja a instância principal ou a instância do pool de leitura.
No prompt de comando psql, conecte-se ao banco de dados que tem a extensão ativada e remova-a:
\cDB_NAMEDROPEXTENSIONEXTENSION_NAME;
Repita a etapa anterior para se conectar a outros bancos de dados que tenham a
extensão ativada e solte a extensão em cada um deles.
Se a extensão exigiu que flags de banco de dados fossem definidas nas instâncias
em que foi usada, remova as flags de cada uma das instâncias em que foi
usada seguindo as instruções em
Configurar flags de banco de dados de uma
instância.
A lista de extensões compatíveis
mostra quais extensões exigem a definição de flags de banco de dados e identifica
quais flags.
[[["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\u003eAlloyDB extensions are enabled by connecting to a database in the primary instance and using a \u003ccode\u003eLOAD\u003c/code\u003e or \u003ccode\u003eCREATE EXTENSION\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eSome extensions require setting specific database flags on the relevant AlloyDB instance, either primary or read pool, before enabling them.\u003c/p\u003e\n"],["\u003cp\u003eDisabling an extension involves connecting to the primary instance and using the \u003ccode\u003eDROP EXTENSION\u003c/code\u003e command within each relevant database.\u003c/p\u003e\n"],["\u003cp\u003eIf database flags were set for an extension, they must be removed from each instance where the extension was used after disabling the extension.\u003c/p\u003e\n"],["\u003cp\u003eThe necessary IAM roles for enabling or disabling extensions are \u003ccode\u003eroles/alloydb.admin\u003c/code\u003e, \u003ccode\u003eroles/owner\u003c/code\u003e, or \u003ccode\u003eroles/editor\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Configure database extensions\n\nThis page describes how to enable and disable PostgreSQL extensions in\nAlloyDB.\n\nSee [Supported database extensions](/alloydb/docs/reference/extensions) for the\nlist of the extensions that AlloyDB supports.\n\n\nBefore you begin\n----------------\n\n- The Google Cloud project you are using must have been [enabled to access AlloyDB](/alloydb/docs/project-enable-access).\n- You must have one of these IAM roles in the Google Cloud project you are using:\n - `roles/alloydb.admin` (the AlloyDB Admin predefined IAM role)\n - `roles/owner` (the Owner basic IAM role)\n - `roles/editor` (the Editor basic IAM role)\n\n If you don't have any of these roles, contact your Organization Administrator to request\n access.\n\n\u003cbr /\u003e\n\nEnable an extension\n-------------------\n\nIn general, you enable an extension by connecting to a database in\nan AlloyDB cluster's primary instance and entering a `LOAD` or\n`CREATE EXTENSION` command.\n\nHowever, some extensions require you to set one or more database flags\n**before** you can use the `LOAD` or `CREATE EXTENSION` command to enable the\nextension. You set these flags on the AlloyDB instance where you\nwant to use the extension, whether that instance is the primary instance or read\npool instance.\n\n### Procedure\n\n1. If required, [set the appropriate database flags](/alloydb/docs/instance-configure-database-flags) on the instance where you\n want to use the extension, either the primary instance or a read pool instance.\n\n The [list of supported extensions](/alloydb/docs/reference/extensions)\n shows which extensions require this step and states which database flags you\n must set.\n2. Connect a `psql` client to the cluster's primary instance, as\n described in [Connect a psql client to\n an instance](/alloydb/docs/connect-psql).\n\n | **Note:** You must connect to the primary instance even if you are enabling the extension on a read pool instance.\n3. At the `psql` command prompt, connect to the database and create the extension: \n\n ```sql\n \\c \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eDB_NAME\u003c/span\u003e\u003c/var\u003e\n CREATE EXTENSION IF NOT EXISTS \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eEXTENSION_NAME\u003c/span\u003e\u003c/var\u003e;\n ```\n | **Note:** To create the [auto_explain](https://www.postgresql.org/docs/16/auto-explain.html) extension, use the \\`LOAD\\` command.\n4. If desired, repeat the previous step to connect to other databases and create the extension in each of them.\n\nDisable an extension\n--------------------\n\nYou disable an extension by reversing the procedure used to enable it.\n\n1. Connect a `psql` client to the cluster's primary instance, as\n described in [Connect a psql client to\n an instance](/alloydb/docs/connect-psql).\n\n | **Note:** You must connect to the primary instance even if you are disabling an extension that is only being used on read pool instances.\n2. At the `psql` command prompt, connect to the database that has the extension enabled and drop the extension: \n\n ```sql\n \\c DB_NAME\n DROP EXTENSION EXTENSION_NAME;\n ```\n3. Repeat the previous step to connect to any other databases that have the extension enabled and drop the extension in each of them.\n4. If the extension required that database flags be set on the instances\n where it was used, remove the flags from each of the instances where it was\n used by following the instructions in\n [Configure an instance's\n database flags](/alloydb/docs/instance-configure-database-flags).\n\n The [list of supported extensions](/alloydb/docs/reference/extensions)\n shows which extensions require setting of database flags and identifies\n which flags."]]