Create a PDB from PDB$SEED or XML

post

/database/pdbs/

Create a pluggable database from PDB$SEED or from an XML metadata file accessible to the database instance. The use of Oracle Transparent Data Encryption is only supported in topologies where the database and Oracle REST Data Services are on the same host. This service requires db.cdb.adminUser credentials to be set in the pool configuration. A client requires SQL Administrator role to invoke this service.

Request

Supported Media Types
Body ()
Root Schema : schema
Type: object
Show Source
  • The administrator username for the new PDB. This property is required when the method property is CREATE.
  • The administrator password for the new PDB. This property is required when the method property is CREATE.
  • Indicate if 'AS CLONE' option should be used in the command to plug in a PDB. This property is applicable when the method property is PLUG but not required.
  • Allowed Values: [ "COPY", "NOCOPY", "MOVE" ]
    Indicate which copy option should be used in the command to plug in a PDB. This property is required when the method property is PLUG.
  • Relevant for create and plug operations. As defined in the Oracle Multitenant Database documentation. Values can be a filename convert pattern or NONE.
  • If defined, the response will contain a JSON object with the information of the script that was generated for execution. A database is not created when this property is set to true.
  • Allowed Values: [ "CREATE", "PLUG" ]
    This property defines the type of operation. Depending on the method specified, other properties will be required in the payload.
  • The name of the new PDB. Relevant to both CREATE and PLUG method.
  • Relevant for create and plug operations. True for temporary file reusage.
  • This property is required when the method property is PLUG. As defined in the Oracle Multitenant Database documentation. Values can be a source filename convert pattern or NONE.
  • TDE import for plug operations.
  • TDE keystore path is required if the tdeImport flag is set to true. Can be used in plug operations.
  • TDE password when applicable (optional). Can be used in create and plug operations.
  • TDE secret is required if the tdeImport flag is set to true. Can be used in plug operations.
  • Relevant for create and clone operations. Total size for temporary tablespace as defined in the Oracle Multitenant Database documentation. See size_clause description in Database SQL Language Reference documentation.
  • Relevant for create and plug operations. Total size as defined in the Oracle Multitenant Database documentation. See size_clause description in Database SQL Language Reference documentation.
  • Relevant for create and plug operations. True for unlimited storage. Even when set to true, totalSize and tempSize MUST be specified in the request if method is CREATE.
  • The path of the XML metadata file to use when plugging-in a PDB.
Back to Top

Response

Supported Media Types

200 Response

The response will indicate the successful execution of a series of PL/SQL statements, or return a set of PL/SQL statements that could be executed to create a pluggable database.
Body ()
Root Schema : RESTSQLCollection
Type: object
Show Source
Nested Schema : items
Type: array
Show Source
Nested Schema : SQLItem
Type: object
Show Source
Nested Schema : response
Type: array
Show Source
Back to Top

Examples

The following example shows how to create a new Pluggable Database by submitting a POST request on the REST resource using cURL.

curl -i -X POST -u username:password 
-d @request_body.json 
-H "Content-Type:application/json" https://rest_server_url/ords/_/db-api/stable/database/pdbs/

Example of Request Body

Note:

The URL structure https://rest_server_url/resource-path, used in the preceding command has the following components:
  • rest_server_url is the REST server where Oracle Rest Data Server is running
  • The remainder of the URL includes the ORDS context root, the version of ORDS Database API to use, and the path for this operation. The PDB Lifecycle Management service requires db.cdb.adminUser credentials to be set in the pool configuration and in this example, the default pool is configured for the container database.

The following is an example request body to create a pluggable database called pdb_sample in this example, from PDB$SEED with unlimited storage. In this example, fileNameConversions parameter is also provided that results in a FILE_NAME_CONVERT clause included in the CREATE PLUGGABLE DATABASE statement executed in the container database:


{
  "method": "CREATE",
  "pdb_name": "pdb_sample",
  "adminName": "pdbadmin",
  "adminPwd": "W3lc0m31",
  "fileNameConversions": "('/disk1/oracle/dbs/pdbseed/','/disk1/oracle/dbs/pdb_sample/')",
  "unlimitedStorage": true,
  "reuseTempFile": true,
  "totalSize": "UNLIMITED",
  "tempSize": "UNLIMITED"
}

The following is an example request body to get the generated script for creating a pluggable database from PDB$SEED with custom storage settings. Note that the script is not executed in the database. In this example, fileNameConversions parameter has a NONE value that results in a FILE_NAME_CONVERT=NONE clause included in the CREATE PLUGGABLE DATABASE statement generated.


{
  "method": "CREATE",
  "pdb_name": "pdb_sample",
  "adminName": "pdbadmin",
  "adminPwd": "W3lc0m31",
  "fileNameConversions": "NONE",
  "reuseTempFile": true,
  "totalSize": "2G",
  "tempSize": "800M",
  "getScript": true
}

The following is an example request body to plugin a pluggable database called sales_pdb into the container database. In this example request body the pluggable database definition is specified in the sales_pdb.xml file:


{
  "method": "PLUG",
  "pdb_name": "sales_pdb",
  "xmlFileName": "/disk1/oracle/dbs/sales_pdb.xml",
  "sourceFileNameConversions": "NONE",
  "copyAction": "NOCOPY",
  "fileNameConversions": "NONE",
  "unlimitedStorage": true,
  "reuseTempFile": true,
  "totalSize": "UNLIMITED",
  "tempSize": "UNLIMITED"
}

Example of Response Header

The following example shows the response header:


HTTP/1.1 200 OK
Date: Fri, 06 Sep 2019 15:51:31 GMT
Content-Type: application/json
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked

Example of Response Body

The following example shows the response body with 200 returned in JSON format:


{
    "statementText": "BEGIN\n\tEXECUTE IMMEDIATE 'CREATE PLUGGABLE DATABASE \"pdb_sample\"\n\t\tUSING ''/disk1/oracle/dbs/sales_db.xml''\n\t\tSOURCE_FILE_NAME_CONVERT=NONE\n\t\tNOCOPY\n\t\tSTORAGE UNLIMITED\tTEMPFILE REUSE\n\t';\nEND;\n/\nALTER PLUGGABLE DATABASE \"pdb_sample\" OPEN READ WRITE INSTANCES=ALL\n/\n",
    "binds": []
}
Back to Top