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

There are no request parameters for this operation.

Back to Top

Response

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.
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