Anda harus memiliki salah satu peran IAM ini di Google Cloud project yang Anda gunakan:
roles/alloydb.admin (peran IAM bawaan Admin AlloyDB)
roles/owner (peran IAM dasar Pemilik)
roles/editor (peran IAM dasar Editor)
Jika Anda tidak memiliki salah satu peran ini, hubungi Administrator Organisasi Anda untuk meminta
akses.
Mengaktifkan ekstensi
Secara umum, Anda mengaktifkan ekstensi dengan terhubung ke database di
instance utama cluster AlloyDB dan memasukkan perintah LOAD atau
CREATE EXTENSION.
Namun, beberapa ekstensi mengharuskan Anda menetapkan satu atau beberapa flag database
sebelum dapat menggunakan perintah LOAD atau CREATE EXTENSION untuk mengaktifkan
ekstensi. Anda menetapkan flag ini pada instance AlloyDB tempat Anda
ingin menggunakan ekstensi, baik instance tersebut adalah instance utama atau instance
kumpulan baca.
Prosedur
Jika diperlukan,
tetapkan flag database yang sesuai pada instance tempat Anda
ingin menggunakan ekstensi, baik instance utama maupun instance kumpulan baca.
Daftar ekstensi yang didukung
menunjukkan ekstensi mana yang memerlukan langkah ini dan menyatakan flag database mana yang harus Anda
tetapkan.
Pada command prompt psql, hubungkan ke database yang mengaktifkan ekstensi dan hapus ekstensi:
\cDB_NAMEDROPEXTENSIONEXTENSION_NAME;
Ulangi langkah sebelumnya untuk terhubung ke database lain yang mengaktifkan ekstensi dan hapus ekstensi di setiap database tersebut.
Jika ekstensi mengharuskan tanda database ditetapkan pada instance
tempat ekstensi digunakan, hapus tanda dari setiap instance tempat ekstensi
digunakan dengan mengikuti petunjuk di
Mengonfigurasi tanda database
instance.
Daftar ekstensi yang didukung
menunjukkan ekstensi mana yang memerlukan penetapan flag database dan mengidentifikasi
flag mana.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]