We do this by create pluggable database statement.
This will copy data files from seed to new location.
This will create system and sysaux tablespaces.
This will create default schemas and common users .
Sys user will be super user.
system user can manage the PDB.
This will create the DB service automatically.
What is the prerequisites for using create pluggable database statement?
• The current container must be root
• You must have create pluggable database privileges
• The CDB must be in READ WRITE mode
- Basic Seed PDB
[oracle@test ~]$ cd /u01/app/oracle/oradata/ORCL/pdbseed/
[oracle@test pdbseed]$ pwd
/u01/app/oracle/oradata/ORCL/pdbseed
[oracle@test pdbseed]$ ll
합계 716884
-rw-r----- 1 oracle oinstall 346038272 11월 11 01:15 sysaux01.dbf
-rw-r----- 1 oracle oinstall 283123712 11월 11 01:15 system01.dbf
-rw-r----- 1 oracle oinstall 37756928 11월 11 01:09 temp012023-11-11_01-06-19-635-AM.dbf
-rw-r----- 1 oracle oinstall 104865792 11월 11 01:15 undotbs01.dbf
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> select con_id, name, open_mode from v$containers;
CON_ID NAME OPEN_MODE
---------- -------------------- ----------
1 CDB$ROOT READ WRITE
2 PDB$SEED READ ONLY
3 ORCLPDB READ WRITE
SQL> alter session set container=PDB$SEED;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
PDB$SEED
SQL> select con_id, username,DEFAULT_TABLESPACE,common from cdb_users;
...
35 rows selected.
SQL> select username,DEFAULT_TABLESPACE,common from dba_users;
...
35 rows selected.
SQL> select con_id,file#, name from V$DATAFILE;
CON_ID FILE# NAME
---------- ---------- ------------------------------------------------------------
2 5 /u01/app/oracle/oradata/ORCL/pdbseed/system01.dbf
2 6 /u01/app/oracle/oradata/ORCL/pdbseed/sysaux01.dbf
2 8 /u01/app/oracle/oradata/ORCL/pdbseed/undotbs01.dbf
SQL> select * from V$TABLESPACE;
TS# NAME INC BIG FLA ENC CON_ID
---------- -------------------- --- --- --- --- ----------
0 SYSTEM YES NO YES 2
1 SYSAUX YES NO YES 2
2 UNDOTBS1 YES NO YES 2
3 TEMP NO NO YES 2
SQL> alter session set container=cdb$root;
Session altered.
[oracle@test ORCL]$ pwd
/u01/app/oracle/oradata/ORCL
[oracle@test ORCL]$ mkdir /u01/app/oracle/oradata/ORCL/pdb1
-- go to vbox
-- mkdir /u01/app/oracle/oradata/ORCL/pdb1
SQL> CREATE PLUGGABLE DATABASE pdb1
ADMIN USER pdb1admin IDENTIFIED BY welcome
ROLES = (dba)
DEFAULT TABLESPACE pdb1
DATAFILE '/u01/app/oracle/oradata/ORCL/pdb1/pdb1_01.dbf' SIZE 250M AUTOEXTEND ON
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/ORCL/pdbseed/',
'/u01/app/oracle/oradata/ORCL/pdb1/')
Pluggable database PDB1 created.
/*
file_name_convert
Use this clause to determine how the database generates the names of files
(such as data files and wallet files) for the PDB.
*/
SQL> select con_id,name,open_mode from v$containers;
CON_ID NAME OPEN_MODE
---------- ------------------------------------------------------------ ----------
1 CDB$ROOT READ WRITE
2 PDB$SEED READ ONLY
3 ORCLPDB READ WRITE
4 PDB1 MOUNTED
SQL> alter session set container=pdb1;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
PDB1
SQL> alter pluggable database open;
Pluggable database altered.
...
[oracle@test pdb1]$ ls -ltr
합계 972888
-rw-r----- 1 oracle oinstall 104865792 11월 24 15:37 undotbs01.dbf
-rw-r----- 1 oracle oinstall 283123712 11월 24 15:37 system01.dbf
-rw-r----- 1 oracle oinstall 346038272 11월 24 15:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 262152192 11월 24 15:37 pdb1_01.dbf
-rw-r----- 1 oracle oinstall 37756928 11월 24 15:37 temp012023-11-11_01-06-19-635-AM.dbf
[oracle@test pdb1]$
SQL> select con_id, username,DEFAULT_TABLESPACE,common from cdb_users order by common;
CON_ID USERNAME DEFAULT_TABLESPACE COMMON
---------- ------------------------- -------------------- ----------
4 PDB1ADMIN PDB1 NO
4 ORDSYS PDB1 YES
4 XS$NULL SYSTEM YES
4 DBSNMP SYSAUX YES
4 APPQOSSYS SYSAUX YES
4 GSMCATUSER PDB1 YES
4 MDDATA PDB1 YES
4 DBSFWUSER SYSAUX YES
4 SYSBACKUP PDB1 YES
4 REMOTE_SCHEDULER_AGENT PDB1 YES
4 GGSYS SYSAUX YES
...
...
37 rows selected.
SQL> select username,DEFAULT_TABLESPACE,common from dba_users;
/*
same as above, ditto.
*/
SQL> select con_id,file#, name from V$DATAFILE;
CON_ID FILE# NAME
---------- ---------- ------------------------------------------------------------
4 13 /u01/app/oracle/oradata/ORCL/pdb1/system01.dbf
4 14 /u01/app/oracle/oradata/ORCL/pdb1/sysaux01.dbf
4 15 /u01/app/oracle/oradata/ORCL/pdb1/undotbs01.dbf
4 16 /u01/app/oracle/oradata/ORCL/pdb1/pdb1_01.dbf
SQL> select * from V$TABLESPACE;
TS# NAME INCLUDED_IN_DATABASE_BACKUP BIG FLA ENC CON_ID
---------- --------------- ---------------------------------------- --- --- --- ----------
0 SYSTEM YES NO YES 4
1 SYSAUX YES NO YES 4
2 UNDOTBS1 YES NO YES 4
3 TEMP NO NO YES 4
5 PDB1 YES NO YES 4
[oracle@test pdb1]$ pwd
/u01/app/oracle/oradata/ORCL/pdb1
[oracle@test pdb1]$
[oracle@test pdb1]$ ls -ltr
합계 716880
-rw-r----- 1 oracle oinstall 37756928 11월 24 15:34 temp012023-11-11_01-06-19-635-AM.dbf
-rw-r----- 1 oracle oinstall 104865792 11월 24 15:34 undotbs01.dbf
-rw-r----- 1 oracle oinstall 346038272 11월 24 15:34 sysaux01.dbf
-rw-r----- 1 oracle oinstall 283123712 11월 24 15:34 system01.dbf
[oracle@test pdb1]$
# after open database
[oracle@test pdb1]$ ls -ltr
합계 972888
-rw-r----- 1 oracle oinstall 104865792 11월 24 15:37 undotbs01.dbf
-rw-r----- 1 oracle oinstall 283123712 11월 24 15:37 system01.dbf
-rw-r----- 1 oracle oinstall 346038272 11월 24 15:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 262152192 11월 24 15:37 pdb1_01.dbf
-rw-r----- 1 oracle oinstall 37756928 11월 24 15:37 temp012023-11-11_01-06-19-635-AM.dbf
[oracle@test pdb1]$
'Database > Oracle' 카테고리의 다른 글
47 - [Oracle 19C] To create PDB from seed PBD(DBCA) (0) | 2023.11.27 |
---|---|
46 - [Oracle 19C] Connecting to the new PDB (0) | 2023.11.25 |
44 - [Oracle 19C] V$SPPARAMETER (0) | 2023.11.24 |
43 - [Oracle 19C] Enable DDL logging (0) | 2023.11.24 |
42 - [Oracle 19C] (ADR)Trace files (0) | 2023.11.24 |