ALTER PLUGGABLE DATABASE
Description
Modifies the status of a PDB, including enabling, disabling, and forcibly disabling the PDB.
Precautions
- This command can be used only when the GUC parameter enable_mtd is set to on.
- This operation can be performed only in the non-PDB. This command cannot be executed in M-compatible databases.
- The operation user must be the PDB owner (see the pg_database.datdba system catalog) or have the SYSADMIN permission.
- Only the initial database user can use this statement to change the template PDB (template_pdb).

- Only the initial database user can connect to the template PDB.
- Do not perform any data operation in the template PDB. Otherwise, unexpected behavior may occur. For example, if tablespaces are created in a template PDB, subsequent PDBs created based on the template will not synchronize the soft links of the tablespaces in the template, and the soft links will be lost.
Syntax
ALTER PLUGGABLE DATABASE pdb_name { OPEN | CLOSE | CLOSE IMMEDIATE };
Parameters
- pdb_name
Specifies the PDB name.
Value range: a string that complies with the Identifier Naming Conventions.
- OPEN
Opens a specified PDB. The OPEN operation of the PDB starts the database instance. That is, the PDB provides services only when it is started. Administrators can enable or disable some PDBs as required. A PDB can be connected only when it is enabled.
A PDB can be successfully opened only when the current resource plan contains resource plan instructions associated with the PDB.
- CLOSE
Closes a specified PDB. If a PDB is no longer used or needs to be deleted, you can perform the CLOSE operation to close PDB services. After the PDB is closed, the PDB cannot be connected. A database performs basic routine maintenance on closed PDBs to ensure the overall consistency within the system. The system overhead of these closed PDBs can be ignored. If a PDB has service connections when you run this statement, wait for a maximum of 5 seconds. If the PDB still has service connections, the PDB fails to be closed.
- CLOSE IMMEDIATE
Forcibly disables a specified PDB. If the administrator cannot disconnect the service connection of a PDB, the administrator can use this option to clear the existing service connection of the PDB and disable the PDB.
Examples
- Prerequisites
For details about how to create a PDB, see Examples in Developer Guide.
- Start and stop a PDB.
-- Connect to the postgres database as a system administrator and open the created PDB. gaussdb=# alter pluggable database my_pdb open; ALTER PLUGGABLE DATABASE -- Connect to the postgres database as a system administrator and attempt to close the PDB that has been opened. gaussdb=# alter pluggable database my_pdb close; ALTER PLUGGABLE DATABASE -- Connect to the postgres database as a system administrator and open the created PDB. gaussdb=# alter pluggable database my_pdb open; ALTER PLUGGABLE DATABASE -- Connect to the postgres database as a system administrator and immediately close the PDB that has been opened. gaussdb=# alter pluggable database my_pdb close immediate; ALTER PLUGGABLE DATABASE
Helpful Links
CREATE PLUGGABLE DATABASE, DROP PLUGGABLE DATABASE INCLUDING DATAFILES, and GS_PDB
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot