[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-25。"],[[["\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."]]