In the previous article, we have seen Introduction of Application Container
In this article we will see creating Application Container, Installing Application in Container, Creating Application PDBs and syncing application PDB with application root.
Step 1: Create an application root database
SQL> CREATE PLUGGABLE DATABASE APP_PDB AS APPLICATION CONTAINER ADMIN USER APP_ADMIN IDENTIFIED BY oracle; Pluggable database created.
Step 2: Open application root database
SQL> ALTER PLUGGABLE DATABASE APP_PDB OPEN; Pluggable database altered.
Step 3: Save open state for this database
SQL> ALTER PLUGGABLE DATABASE APP_PDB SAVE STATE; Pluggable database altered. SQL>
Step 4: Check from v$pdbs view
SQL> SELECT CON_ID,NAME,OPEN_MODE FROM V$PDBS WHERE APPLICATION_ROOT='YES'; CON_ID NAME OPEN_MODE ---------- --------------------------------------------------------- 4 APP_PDB READ WRITE SQL>
Step 5: View datafile and tablespace of application container :
SQL> SELECT FILE_NAME,TABLESPACE_NAME FROM CDB_DATA_FILES WHERE CON_ID=4; FILE_NAME TABLESPACE_NAME --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------ /u02/oradata/TESTCDB/71DA02D769265585E055000000000001/datafile/o1_mf_system_fokrl9lc_.dbf SYSTEM /u02/oradata/TESTCDB/71DA02D769265585E055000000000001/datafile/o1_mf_sysaux_fokrl9lr_.dbf SYSAUX /u02/oradata/TESTCDB/71DA02D769265585E055000000000001/datafile/o1_mf_undotbs1_fokrl9ls_.dbf UNDOTBS1
We can see here SYSTEM, SYSAUX and UNDO tablespaces are created in application root.
Set container to application container.
SQL> alter session set container=app_pdb; Session altered.
Step 6: Check granted privilege to application container admin user.
SQL> SELECT GRANTEE,GRANTED_ROLE,COMMON FROM DBA_ROLE_PRIVS WHERE GRANTEE='APP_ADMIN'; GRANTEE GRANTED_ROLE COM -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- --- APP_ADMIN PDB_DBA NO
Step 7: Check privilege of PDB_DBA role.
SQL> SELECT ROLE,PRIVILEGE,ADMIN_OPTION,INHERITED FROM ROLE_SYS_PRIVS WHERE ROLE='PDB_DBA'; ROLE PRIVILEGE ADM INH ---------------------------------------------------------------------------------------------- ---------------------------------------- --- --- PDB_DBA CREATE SESSION NO NO PDB_DBA SET CONTAINER NO NO PDB_DBA CREATE PLUGGABLE DATABASE NO NO
Step 8: Create tns entry for application pdb :
app_pdb = (description = (address = (protocol=TCP) ( HOST=localhost)(port=1521)) (connect_data = (server =DEDICATED) (SERVICE_NAME=app_pdb) ) )
Step 9: Connect to application container and install the application using begin install and version
SQL> alter session set container=app_pdb; Session altered. SQL> ALTER PLUGGABLE DATABASE APPLICATION APP_PDB BEGIN INSTALL '1.0'; Pluggable database altered.
Step 10: We will create one user and create some tables and data for that user.
SQL> CREATE TABLESPACE SAL_TBS DATAFILE SIZE 100M; Tablespace created. SQL> CREATE USER SAL_USR IDENTIFIED BY oracle DEFAULT TABLESPACE SAL_TBS QUOTA UNLIMITED ON SAL_TBS; User created. SQL> GRANT CONNECT,CREATE TABLE TO SAL_USR;
Step 11: Connect to that schema
SQL> ALTER SESSION SET CURRENT_SCHEMA=SAL_USR; Session altered.
Step 12: Create a table in SAL_USR schema :
SQL> CREATE TABLE SAL_MST(NAME VARCHAR2(100),DESCRIPTION VARCHAR2(200)); Table created. SQL> INSERT INTO SAL_MST VALUES ('ID001','THIS IS TEST ENTRY'); 1 row created. SQL> COMMIT; Commit complete.
Step 13: End application installation using END INSTALL :
SQL> ALTER PLUGGABLE DATABASE APPLICATION APP_PDB END INSTALL '1.0'; Pluggable database altered.
Step 14: Check the application version from DBA_APPLICATIONS :
SQL> SELECT APP_NAME,APP_VERSION,APP_STATUS,APP_IMPLICIT FROM DBA_APPLICATIONS WHERE APP_IMPLICIT='N'; APP_NAME APP_VERSION APP_STATUS A -------------------------------------------------------------------------------------------------------------------------------- ------------------------------ ------------ - APP_PDB 1.0 NORMAL N
Stay tuned for More articles on Oracle Multitenant
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
Telegram Channel: https://t.me/helporacle
Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/
Joel Perez’s LinkedIn: Joel Perez’s Profile
LinkedIn Group: Oracle Cloud DBAAS
Facebook Page: OracleHelp