A new pluggable database (PDB) needs Oracle's system foundation before application objects can be added. Creating it from PDB$SEED copies the seed's files to a new location and associates the copies with the new PDB. The original seed remains available for subsequent creations.
Oracle DBA Lesson 48 Part 1 — Create a PDB from the Seed
What the seed supplies
PDB$SEED is Oracle's read-only template. It supplies the system content and dictionary information a new PDB needs. A data dictionary describes database objects and supports their management. A seed-derived PDB is ready for later configuration and application deployment. Application business rows are installed separately. See multitenant architecture.
The new PDB has its own data files on persistent storage, including files for SYSTEM and SYSAUX. Those two families explain the copy. They are not the whole storage inventory. Temporary files also have to be accounted for, and so does local undo storage when local undo is enabled. Seed-derived PDBs keep Oracle's metadata-link architecture: some Oracle-supplied definitions stay in the root and are linked from the PDB. Copying the seed files leaves those shared definitions in the root.
A PDB is a container boundary inside a CDB. It shares that CDB's instance and other CDB resources. Creation adds the PDB. The instance, online redo logs, and control files stay with the CDB.
Conditions before creation
The CDB must be open READ WRITE, and the current container must be CDB$ROOT. CREATE PLUGGABLE DATABASE must be granted commonly. Confirm the release, edition, licensed functionality, PDB-count entitlement, and capacity. A setting that allows more PDBs is not evidence of entitlement. See creating a PDB from scratch and licensing information.
Choose a PDB name that is not already in use. Check the listener's service namespace across the CDBs it serves, because the new PDB's default service can collide with an existing service. This lesson uses APP_PDB and the local administrator APP_ADMIN. Account for capacity, directory permissions, and any encryption or keystore requirement for the new files.
In SQL*Plus, inspect the current context:
SHOW USER
SHOW CON_NAME
SELECT name, open_mode FROM v$pdbs ORDER BY con_id;
SHOW PARAMETER db_create_file_dest
SHOW PARAMETER pdb_file_name_convert
One starting row:
| NAME | OPEN_MODE |
|---|---|
| PDB$SEED | READ ONLY |
SHOW CON_NAME identifies CDB$ROOT for this root operation. V$PDBS lists the PDBs associated with the instance. The seed row leaves the creation privilege, the root open mode, licensing, free space, and service-name uniqueness still to be checked. See V$PDBS.
Choose how new file names are formed
| Method | Meaning for files created by this statement |
|---|---|
FILE_NAME_CONVERT clause | Explicit pattern replacement from source names to target names. These files are not Oracle Managed Files. |
CREATE_FILE_DEST clause | Sets a PDB-specific Oracle Managed Files destination. |
Root DB_CREATE_FILE_DEST | Supplies an Oracle Managed Files destination when a higher-precedence clause does not apply. |
PDB_FILE_NAME_CONVERT parameter | Fallback name mapping when the statement omits its conversion clause and Oracle Managed Files is not enabled. |
This order applies to the files created during PDB creation. When both FILE_NAME_CONVERT and CREATE_FILE_DEST are specified, the conversion clause places the creation-time files, and CREATE_FILE_DEST becomes the PDB's default for later Oracle Managed Files creation. The statement in this lesson uses neither clause. It relies on the root DB_CREATE_FILE_DEST setting. See PDB creation.
Managed-file example
| NAME | TYPE | VALUE |
|---|---|---|
| db_create_file_dest | string | /dbdata |
With this usable destination and no file-conversion clause, Oracle generates unique file names beneath it. It may create database and container subdirectories, including a GUID directory. After creation, read the complete recorded file names, including the generated suffixes. A file-system destination must already exist, allow the database to create files, and have enough capacity. An eligible ASM disk group is another supported destination. A directory name alone does not establish the placement. See DB_CREATE_FILE_DEST.
CREATE_FILE_DEST = '/dbdata/app_pdb' is an alternative PDB-specific managed destination, with the same directory and access requirements. The statement below does not use it.
Explicit conversion example
For a separate source path that is not Oracle Managed Files, a clause can map a seed-directory prefix:
FILE_NAME_CONVERT = ('/dbfiles/seed/', '/dbfiles/app_pdb/')
| Source name | New name |
|---|---|
| /dbfiles/seed/system01.dbf | /dbfiles/app_pdb/system01.dbf |
| /dbfiles/seed/sysaux01.dbf | /dbfiles/app_pdb/sysaux01.dbf |
The originals stay at the source. The new names belong to the copies at the target. Confirm the source prefixes, every required file, target write access, capacity, and the absence of name collisions. Patterns in this clause, or in PDB_FILE_NAME_CONVERT, cannot match Oracle-managed files or directories. This prefix belongs to the non-OMF source path shown here. It is not a mapping for managed-file paths. PDB_FILE_NAME_CONVERT by itself does not enable Oracle Managed Files. See PDB_FILE_NAME_CONVERT.
PATH_PREFIX governs relevant directory-object paths and certain associated files. Data-file placement follows the rules above. PATH_PREFIX does not affect Oracle Managed Files. See CREATE PLUGGABLE DATABASE.
Create from the seed with a local administrator
The statement uses the root managed-file destination and no conversion override. SQL*Plus reads the local administrator password through substitution. The secret has to be valid inside quoted SQL*Plus substitution: no double quote, and no substitution metacharacter that changes the script.
SET VERIFY OFF
SET ECHO OFF
SPOOL OFF
ACCEPT pdb_admin_secret CHAR PROMPT 'New PDB administrator password: ' HIDE
CREATE PLUGGABLE DATABASE app_pdb
ADMIN USER app_admin IDENTIFIED BY "&pdb_admin_secret";
UNDEFINE pdb_admin_secret
ACCEPT ... HIDE reads the value without displaying the typed characters. SET VERIFY OFF suppresses substitution echo. SET ECHO OFF stops command echo, and SPOOL OFF closes an open spool. UNDEFINE removes the SQL*Plus substitution variable after use and leaves the account password unchanged. See SQL*Plus ACCEPT.
The statement has no FROM clause, so creation uses the PDB seed. ADMIN USER creates APP_ADMIN locally inside APP_PDB. It does not create a common CDB administrator. Oracle grants the PDB_DBA role to this user locally. Review that role's contents and the direct grants the account needs, including CREATE SESSION. The role name is not unrestricted administration, and ROLES=(DBA) is not a substitute for that review.
There is no DEFAULT TABLESPACE clause, so this statement creates no application tablespace. Set up application storage, quotas, and least-privilege accounts for the workload before deployment.
Interpret the immediate result
SELECT name, open_mode FROM v$pdbs
WHERE name = 'APP_PDB';
| NAME | OPEN_MODE |
|---|---|
| APP_PDB | MOUNTED |
Successful creation leaves the new PDB mounted, with status NEW. Open mode and lifecycle status are separate columns in separate views: V$PDBS.OPEN_MODE, and DBA_PDBS.STATUS or CDB_PDBS.STATUS. The files are created and registered. Ordinary application work waits until the PDB is open.
From the root, the control-file inventory of the new container's data files is:
SELECT p.name AS pdb_name, d.file#, d.name AS file_name
FROM v$datafile d
JOIN v$pdbs p ON p.con_id = d.con_id
WHERE p.name = 'APP_PDB'
ORDER BY d.file#;
V$DATAFILE reports data-file information from the control file. The recorded names show the placement that was created. Readable headers, every storage file type, recovery readiness, and application availability each need their own check. Temporary files need their own inventory. A broader CDB_DATA_FILES listing depends on container visibility and on the PDB being open. A missing dictionary result while the PDB is mounted is a visibility limit, not a failed creation. See V$DATAFILE.
The first READ WRITE opening completes integration and changes the lifecycle status to NORMAL. That opening, restricted-state and plug-in checks, service login, saved open state, and the backup baseline are the next part. A default service being created leaves the client route still to be tested.
If creation returns an error, inspect the status and the alert log. A PDB can be left UNUSABLE. Retrying the same name, adding TEMPFILE REUSE without a diagnosis, or deleting paths leaves that failure in place. Use the documented removal procedure for that PDB. An unusable PDB is dropped before its name can be reused.
Recap
Seed creation copies files from PDB$SEED into a new PDB and leaves the seed in place. Creation-time file names come from FILE_NAME_CONVERT, then CREATE_FILE_DEST, then the root DB_CREATE_FILE_DEST, then PDB_FILE_NAME_CONVERT. With no placement clause and a usable root destination, Oracle generates managed file names. ADMIN USER creates a local administrator in the new PDB and grants PDB_DBA there. Success leaves the PDB MOUNTED with status NEW. The recorded file paths show where those files were created.
No comments:
Post a Comment