# Oracle Database Setup


# Windows


create PLUGGABLE DATABASE demo ADMIN USER PDB\_ADMIN IDENTIFIED BY oracle FILE\_NAME\_CONVERT \= ('C:\\oracle\\app\\193c\\oradata\\PROD1\\pdbseed\\','C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\demo');

alter session set container=demo;

startup;

CREATE OR REPLACE DIRECTORY PLUGGABLE\_DATA\_PUMP\_DIR as 'C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\';

GRANT READ, WRITE ON DIRECTORY PLUGGABLE\_DATA\_PUMP\_DIR TO SYSTEM;

create tablespace FUND\_TABLESPACE datafile 'C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\FUND\_TABLESPACE.DBF' SIZE 1012m AUTOEXTEND ON NEXT 200M;

create temporary tablespace TEMP\_FUND\_TABLESPACE tempfile 'C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\TEMP\_FUND\_TABLESPACE' SIZE 1012m AUTOEXTEND ON NEXT 200M;

create tablespace USERS datafile 'C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\USERS.DMP' SIZE 526m AUTOEXTEND ON NEXT 200M;

create user fm identified by O\_install#4 default tablespace FUND\_TABLESPACE TEMPORARY tablespace TEMP\_FUND\_TABLESPACE QUOTA UNLIMITED ON FUND\_TABLESPACE;

Grant dba to fm;

-- Before the next command ensure you have copied the dump file to the demo directory---

impdp fm/O\_install#4@demo dumpfile=demo.dmp  metrics=y transport\_datafiles='C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\FUND\_TABLESPACE.DBF', 'C:\\oracle\\app\\193c\\oradata\\PROD1\\demo\\demo.dmp' version=19.3.0 schemas=fm directory=PLUGGABLE\_DATA\_PUMP\_DIR

# Linux


create PLUGGABLE DATABASE demo  ADMIN USER PDB\_ADMIN IDENTIFIED BY oracle FILE\_NAME\_CONVERT \= ('/u01/app/oracle/oradata/ORCL/pdbseed','/u01/app/oracle/oradata/ORCL/demo');

alter session set container\=demo;

startup;

CREATE OR REPLACE DIRECTORY PLUGGABLE\_DATA\_PUMP\_DIR as '/u01/app/oracle/oradata/ORCL/demo';

GRANT READ, WRITE ON DIRECTORY PLUGGABLE\_DATA\_PUMP\_DIR TO SYSTEM;

create tablespace FUND\_TABLESPACE datafile '/u01/app/oracle/oradata/ORCL/demo/FUND\_TABLESPACE.DBF' SIZE 1012m AUTOEXTEND ON NEXT 200M;

create temporary tablespace TEMP\_FUND\_TABLESPACE tempfile '/u01/app/oracle/oradata/ORCL/demo/TEMP\_FUND\_TABLESPACE' SIZE 1012m AUTOEXTEND ON NEXT 200M;

create tablespace USERS datafile '/u01/app/oracle/oradata/ORCL/demo/USERS.DMP' SIZE 526m AUTOEXTEND ON NEXT 200M;
\-- replace #password with your password
create user fm identified by #password default tablespace FUND\_TABLESPACE TEMPORARY tablespace TEMP\_FUND\_TABLESPACE QUOTA UNLIMITED ON FUND\_TABLESPACE;

Grant dba to fm;

-- Before the next command ensure you have copied the dump file to the demo directory---
-- replace #password with your password

!impdp fm/#password@demo dumpfile=demo.dmp  metrics=y transport\_datafiles='/u01/app/oracle/oradata/ORCL/demo/FUND\_TABLESPACE.DBF', 'demo.dmp' version=19 schemas=fm directory=PLUGGABLE\_DATA\_PUMP\_DIR
  • For linux and windows start the listener using the command:

    lsnrctl start
    

# Important Commands

# Starting database

  • [x] sqlplus sys as sysdba
  • [x] startup;
  • [x] alter pluugable database demo open;

# Starting database (Using Bash Script)

  • Create a file with the extentions .sh
  • configure the files in references to your dump file
#!/bin/bash

export PLUGGABLE_NAME=
export ALL_PLUGGABLES=
read -p 'Do You want to start all the pluggables: type "y/yes"   ' ALL_PLUGGABLES
ALL_PLUGGABLES=${ALL_PLUGGABLES:-y}

if [ "$ALL_PLUGGABLES" == "n" ] || [ "$ALL_PLUGGABLES" == "No" ]|| [ "$ALL_PLUGGABLES" == "no" ]|| [ "$ALL_PLUGGABLES" == "NO" ]; then
    read -p 'Type the name of the Pluggable you want to start: ' PLUGGABLE_NAME
    PLUGGABLE_NAME=${PLUGGABLE_NAME}
fi

echo "************************* switching user oracle *************************" 

sudo su - oracle <<EOF
# The rest of your script goes here
# ...

echo "************************* starting listener *************************" 

lsnrctl start

echo "************************* Starting Oracle *************************" 

# Step 4: Creating Pluggables
sqlplus / as sysdba <<SQL
 startup;
SQL

if [ "$ALL_PLUGGABLES" == "n" ] || [ "$ALL_PLUGGABLES" == "No" ]; then
    # Step 3: Creating Pluggables
sqlplus / as sysdba <<SQL
 alter session set container="$PLUGGABLE_NAME";
SQL

else 

 # Step 3: starting pluggable
sqlplus / as sysdba <<SQL
 alter pluggable database all open;
SQL

fi


EOF


# starting the listener services

  • [x] lsnrctl start

# Stopping listerner services

  • [x] lsnrctl stop

# Refreshing listerner services

  • [x] lsnrctl reload

# Droping pluggable database

  • [x] alter pluggable database dbname close;

  • [x] drop pluggable database dbname including datafiles;

# Creating pluggable database

  • This two paths are dependent on the location of oradata directory '/opt/oracle/oradata/ORCLCDB/pdbseed/', '/opt/oracle/oradata/ORCLCDB/demo/ so replace them in the sql below to the paths of your machine
create PLUGGABLE DATABASE demo ADMIN USER PDB_ADMIN IDENTIFIED BY oracle FILE_NAME_CONVERT = ('/opt/oracle/oradata/ORCLCDB/pdbseed/','/opt/oracle/oradata/ORCLCDB/demo/');

alter session set container=demo;

startup;

CREATE OR REPLACE DIRECTORY PLUGGABLE_DATA_PUMP_DIR as '/opt/oracle/oradata/ORCLCDB/demo/';

GRANT READ, WRITE ON DIRECTORY PLUGGABLE_DATA_PUMP_DIR TO SYSTEM;

create tablespace FUND_TABLESPACE datafile '/opt/oracle/oradata/ORCLCDB/demo/FUND_TABLESPACE.DBF' SIZE 1012m AUTOEXTEND ON NEXT 200M;

create temporary tablespace TEMP_FUND_TABLESPACE tempfile '/opt/oracle/oradata/ORCLCDB/demo/TEMP_FUND_TABLESPACE' SIZE 1012m AUTOEXTEND ON NEXT 200M;

create tablespace USERS datafile '/opt/oracle/oradata/ORCLCDB/demo/USERS.DMP' SIZE 526m AUTOEXTEND ON NEXT 200M;

create user fm identified by fm1232020 default tablespace FUND_TABLESPACE TEMPORARY tablespace TEMP_FUND_TABLESPACE QUOTA UNLIMITED ON FUND_TABLESPACE;

Grant dba to fm;

# Add TNSNAME for our pluggable

  • [x] vi path/to/tnsname.ora e.g /u01/app/oracle/product/19.3/dbhome_1/network/admin/tnsnames.ora
  • [x] Insert the following at the end of the file DEMO = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = demo) ) )
  • [x] Reload the listener to register the service name lsnrctl reload
  • [x] Check status of services lsnrctl services

# Import pluggable database

  • [x] Before the next command ensure you have copied the dump file to the demo directory---

  • [x] -- oustside sqlplus impdp fm/fm1232020@demo dumpfile=demo.dmp metrics=y transport_datafiles='/opt/oracle/oradata/ORCLCDB/demo/FUND_TABLESPACE.DBF', '/opt/oracle/oradata/ORCLCDB/demo.dmp' version=19.3.0 schemas=fm directory='PLUGGABLE_DATA_PUMP_DIR'

  • [x] -- inside sqlplus

    !impdp fm/fm1232020@demo dumpfile=demo.dmp  metrics=y transport_datafiles='/opt/oracle/oradata/ORCLCDB/demo/FUND_TABLESPACE.DBF', '/opt/oracle/oradata/ORCLCDB/demo.dmp' version=19.3.0 schemas=fm directory=PLUGGABLE_DATA_PUMP_DIR
    
  • [x] Exporting Database from Oracle

    expdp fm/password@dbname dumpfile=dumpfilename.dmp version=19 schemas=fm directory=PLUGGABLE_DATA_PUMP_DIR
    

    # Import pluggable database (Using Bash Script)

  • Create a file with the extentions .sh

  • configure the files in references to your dump file

#!/bin/bash

# Set Oracle environment variables for the first user
export ORACLE_SID="dump_database"
export ORACLE_USERNAME="sys"

# Set PDB and dump file information
export EXISTING_PDB_NAME="dump_database"
export NEW_PDB_NAME="dump_database"
export FOLDER_NAME="dump_database"
export DUMP_NAME="dump_database.dmp"
export PDB_ADMIN_USER="oracle_user"
export PDB_ADMIN_PASSWORD="user_password"
export DUMP_FILE_PATH="/home/user/Documents/database_tools/oracle_dumps/dump_database.dmp"
export PLUGGABLE_ORCL="/u01/app/oracle/oradata/ORCL"

echo "************************* copying dump to oracle *************************"

cp "$DUMP_FILE_PATH" "$PLUGGABLE_ORCL"/"$FOLDER_NAME"

echo "************************* switching user oracle *************************"
# Switch to the oracle user
sudo su - oracle <<EOF

echo "************************* Updating Permissions & Ownership **************************"
sudo chown -R oracle:oinstall "$PLUGGABLE_ORCL"/"$FOLDER_NAME"/"$DUMP_NAME"
sudo chmod +x  "$PLUGGABLE_ORCL"/"$FOLDER_NAME"/"$DUMP_NAME"

echo "************************* Importing New Dump **************************"

impdp "$PDB_ADMIN_USER"/"$PDB_ADMIN_PASSWORD"@localhost:1522/"$NEW_PDB_NAME" dumpfile="$DUMP_NAME" metrics=y transport_datafiles='$PLUGGABLE_ORCL/$FOLDER_NAME/FUND_TABLESPACE.DBF', '$PLUGGABLE_ORCL/$FOLDER_NAME/FUND_TABLESPACE.DBF' version=19.3.0 schemas=fm directory=PLUGGABLE_DATA_PUMP_DIR

EOF

# INSTALLING ORACLE 21C IN ORACLE LINUX 8

Set the correct hostname in the "/etc/hostname" file.

 sudo su && hostnamectl set-hostname YOUR_HOSTNAME

The "/etc/hosts" file must contain a fully qualified name for the server.

vim /etc/hosts
MACHINE_IP_ADDRESS  YOUR_HOSTNAME.localdomain  YOUR_HOSTNAME

Use the "oracle-database-preinstall-21c" package to perform all your prerequisite setup.

dnf install -y oracle-database-preinstall-21c
dnf install -y bc
dnf install -y binutils
dnf install -y compat-openssl10
dnf install -y elfutils-libelf
dnf install -y glibc
dnf install -y glibc-devel
dnf install -y ksh
dnf install -y libaio
dnf install -y libXrender
dnf install -y libX11
dnf install -y libXau
dnf install -y libXi
dnf install -y libXtst
dnf install -y libgcc
dnf install -y libnsl
dnf install -y libstdc++
dnf install -y libxcb
dnf install -y libibverbs
dnf install -y make
dnf install -y policycoreutils
dnf install -y policycoreutils-python-utils
dnf install -y smartmontools
dnf install -y sysstat
dnf install -y unixODBC

dnf update -y

Set the password for the "oracle" user.

passwd oracle

Set secure Linux to permissive by editing the "/etc/selinux/config".

SELINUX=permissive

Enforce change

setenforce Permissive

Disable firewall.

systemctl stop firewalld
systemctl disable firewalld

Create the directories in which the Oracle software will be installed.

mkdir -p /u01/app/oracle/product/21.0.0/dbhome_1
mkdir -p /u02/oradata
chown -R oracle:oinstall /u01 /u02
chmod -R 775 /u01 /u02

Show Machine name

hostname

Login as root and issue the following command.

# replace MACHINE_NAME with hostname above

xhost +MACHINE_NAME

Create a "scripts" directory.

mkdir /home/oracle/scripts
# replace YOUR_HOSTNAME with hostname

cat > /home/oracle/scripts/setEnv.sh <<EOF
# Oracle Settings
export TMP=/tmp
export TMPDIR=\$TMP

export ORACLE_HOSTNAME=YOUR_HOSTNAME.localdomain
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/21.0.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=cdb1
export PDB_NAME=pdb1
export DATA_DIR=/u02/oradata

export PATH=/usr/sbin:/usr/local/bin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$PATH

export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
EOF

Add a reference to the "setEnv.sh" file at the end of the "/home/oracle/.bash_profile" file.

echo ". /home/oracle/scripts/setEnv.sh" >> /home/oracle/.bash_profile

Create a "start_all.sh" and "stop_all.sh" script that can be called from a startup/shutdown service. Make sure the ownership and permissions are correct.

cat > /home/oracle/scripts/start_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbstart \$ORACLE_HOME
EOF


cat > /home/oracle/scripts/stop_all.sh <<EOF
#!/bin/bash
. /home/oracle/scripts/setEnv.sh

export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbshut \$ORACLE_HOME
EOF

chown -R oracle:oinstall /home/oracle/scripts
chmod u+x /home/oracle/scripts/*.sh

Download the software here (opens new window) and copy the file to ORACLE_HOME directory

# replace ORACLE_HOME with directory

cd ORACLE_HOME &&  chown oracle:oinstall ORACLE_HOME/LINUX.X64_213000_db_home.zip

# Installation

Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable.

# replace MACHINE_NAME with hostname

DISPLAY=MACHINE_NAME:0.0; 
export DISPLAY
cd $ORACLE_HOME

unzip -oq /path/to/software/LINUX.X64_213000_db_home.zip
# do not exclude backslashes \

./runInstaller -ignorePrereq -waitforcompletion -silent                        \
    -responseFile ${ORACLE_HOME}/install/response/db_install.rsp               \
    oracle.install.option=INSTALL_DB_SWONLY                                    \
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         \
    UNIX_GROUP_NAME=oinstall                                                   \
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        \
    SELECTED_LANGUAGES=en,en_GB                                                \
    ORACLE_HOME=${ORACLE_HOME}                                                 \
    ORACLE_BASE=${ORACLE_BASE}                                                 \
    oracle.install.db.InstallEdition=EE                                        \
    oracle.install.db.OSDBA_GROUP=dba                                          \
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    \
    oracle.install.db.OSDGDBA_GROUP=dba                                        \
    oracle.install.db.OSKMDBA_GROUP=dba                                        \
    oracle.install.db.OSRACDBA_GROUP=dba                                       \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 \
    DECLINE_SECURITY_UPDATES=true

As root user execute

sh /u01/app/oracle/product/21.0.0/dbhome_1/root.sh

# Database Creation

You create a database using the Database Configuration Assistant (DBCA)

lsnrctl start

# do not exclude backslashes \

dbca -silent -createDatabase                                                   \
     -templateName General_Purpose.dbc                                         \
     -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID} -responseFile NO_VALUE         \
     -characterSet AL32UTF8                                                    \
     -sysPassword SysPassword1                                                 \
     -systemPassword SysPassword1                                              \
     -createAsContainerDatabase true                                           \
     -numberOfPDBs 1                                                           \
     -pdbName ${PDB_NAME}                                                      \
     -pdbAdminPassword PdbPassword1                                            \
     -databaseType MULTIPURPOSE                                                \
     -memoryMgmtType auto_sga                                                  \
     -totalMemory 2000                                                         \
     -storageType FS                                                           \
     -datafileDestination "${DATA_DIR}"                                        \
     -redoLogFileSize 50                                                       \
     -emConfiguration NONE                                                     \
     -ignorePreReqs

# Post Installation

Edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.

cdb1:/u01/app/oracle/product/21.0.0/dbhome_1:Y

Enable Oracle Managed Files (OMF) and make sure the PDB starts when the instance starts.

sqlplus / as sysdba <<EOF
alter system set db_create_file_dest='${DATA_DIR}';
alter pluggable database ${PDB_NAME} save state;
exit;
EOF

# Start the database

you should be able to start/stop the database with the following scripts run from the "oracle" user

~/scripts/start_all.sh

You can stop the database using :

~/scripts/stop_all.sh

# Patching Oracle 19c

Article Reference (opens new window)

After release of Oracle 19c database, oracle released patches that addressed many security loopholes in the release. This section covers how to apply a patch to oracle 19c

Ensure to get the OS version where the database is running and the type ie single standalone or Grid Infrastructure

Ensure there is a backup of database or vm.

Login to Oracle Account

  1. Download OPatch - A utility for applying patch.
  2. Download the patch to apply

# Steps to applying Patching

# 1. Check oraInventory

If the directory is empty, rebuild it using:

$ORACLE_HOME/oui/bin/runInstaller -silent -ignoreSysPrereqs -attachHome \
  -invPtrLoc $ORACLE_HOME/oraInst.loc \
  ORACLE_HOME=$ORACLE_HOME \
  ORACLE_HOME_NAME="OraDB19Home1"

# 2. Update OPatch Utility

  1. Check OPatch version
    cd $ORACLE_HOME/OPatch
    ./opatch version
    OPatch Version: 12.2.0.1.17
    OPatch succeeded.
    
  2. Backup the existing OPatch
    cd $ORACLE_HOME/
    mv OPatch OPatch_bkp
    

# 3. Upgrade OPatch

Upgrade the OPATCH utility, just unzip the newly downloaded opatch utility version in ORACLE_HOME directly.

unzip /u02/p6880880_190000_Linux-x86-64 -d $ORACLE_HOME/

Check the OPATCH version again.

./opatch version
OPatch Version: 12.2.0.1.35
OPatch succeeded.

# 4. Verify the Database Current version

select BANNER_FULL from v$version;
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

Check dba_registry status

SQL>col comp_id for a10
SQL>col version for a11
SQL>col status for a10
SQL>col comp_name for a37
SQL>select comp_id,comp_name,version,status from dba_registry;
COMP_ID    COMP_NAME                             VERSION     STATUS
---------- ------------------------------------- ----------- ----------
CATALOG    Oracle Database Catalog Views         19.0.0.0.0  VALID
CATPROC    Oracle Database Packages and Types    19.0.0.0.0  VALID
RAC        Oracle Real Application Clusters      19.0.0.0.0  OPTION OFF
JAVAVM     JServer JAVA Virtual Machine          19.0.0.0.0  VALID
XML        Oracle XDK                            19.0.0.0.0  VALID
CATJAVA    Oracle Database Java Packages         19.0.0.0.0  VALID
APS        OLAP Analytic Workspace               19.0.0.0.0  VALID
XDB        Oracle XML Database                   19.0.0.0.0  VALID
OWM        Oracle Workspace Manager              19.0.0.0.0  VALID
CONTEXT    Oracle Text                           19.0.0.0.0  VALID
ORDIM      Oracle Multimedia                     19.0.0.0.0  VALID
SDO        Spatial                               19.0.0.0.0  VALID
XOQ        Oracle OLAP API                       19.0.0.0.0  VALID
OLS        Oracle Label Security                 19.0.0.0.0  VALID
DV         Oracle Database Vault                 19.0.0.0.0  VALID
15 rows selected.

# 5. Apply the patch

Unzip the patch

unzip /u02/p34133642_19.16.00_Linux-x86-64.zip -d /u02

Check prerequisites

Navigate in unzipped folder

cd /u02/34133642  # can be different 
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Sample Output

Oracle Interim Patch Installer version 12.2.0.1.35
Copyright (c) 2023, Oracle Corporation.  All rights reserved.
PREREQ session
Oracle Home       : /u02/app/oracle/product/19.3.0/db_home
Central Inventory : /u01/app/oraInventory
   from           : /u02/app/oracle/product/19.3.0/db_home/oraInst.loc
OPatch version    : 12.2.0.1.35
OUI version       : 12.2.0.7.0
Log file location : /u02/app/oracle/product/19.3.0/db_home/cfgtoollogs/opatch/opatch2023-01-12_23-58-36PM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.

Stop all database service.

SQL> shutdown immediate;

## stop services
lsnrctl stop
ps -ef|grep pmon
oracle    3027 30927  0 00:00 pts/3    00:00:00 grep --color=auto pmon
oracle    3376     1  0 Jan12 ?        00:00:01 ora_pmon_orcl

ps -ef|grep tns
root        14     2  0 Jan12 ?        00:00:00 [netns]
oracle    3035 30927  0 00:00 pts/3    00:00:00 grep --color=auto tns
oracle    6197     1  0 Jan12 ?        00:00:01 /u02/app/oracle/product/19.3.0/db_home/bin/tnslsnr LISTENER -inherit

# 6. Execute OPatch apply

cd /u02/34133642
$ORACLE_HOME/OPatch/opatch apply

Patching component oracle.precomp.common, 19.0.0.0.0...
Patching component oracle.precomp.lang, 19.0.0.0.0...
Patching component oracle.jdk, 1.8.0.201.0...
Patch 34133642 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [34133642].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u02/app/oracle/product/19.3.0/db_home/cfgtoollogs/opatch/opatch2023-01-13_00-09-07AM_1.log
OPatch succeeded.

# 7. Start all database services

lsnrctl start LISTENER

start database

sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jan 13 00:33:15 2023
Version 19.16.0.0.0
Copyright (c) 1982, 2022, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup
ORACLE instance started.
Total System Global Area 2466250360 bytes
Fixed Size                  9137784 bytes
Variable Size             570425344 bytes
Database Buffers         1879048192 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  YES
         3 PDB                            MOUNTED
 
SQL> alter session set container=PDB;
Session altered.

SQL> ALTER DATABASE OPEN;
Database altered.

SQL> SHOW PDBS
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB                            READ WRITE YES

# 7. Post Patch Steps

Now it's time to run datapatch -verbose which updates the patch information at the database binary & dictionary level as well as binary files.

cd $ORACLE_HOME/OPatch
./datapatch -verbose

Once datapatch -verbose is completed then execute the utlrp script to validate the invalid objects.

SQL> @?/rdbms/admin/utlrp.sql
Session altered.

Check applied patch details using lsinventory command.

./opatch lsinventory

Oracle Interim Patch Installer version 12.2.0.1.35
Copyright (c) 2023, Oracle Corporation.  All rights reserved.
Oracle Home       : /u02/app/oracle/product/19.3.0/db_home
Central Inventory : /u01/app/oraInventory
   from           : /u02/app/oracle/product/19.3.0/db_home/oraInst.loc
OPatch version    : 12.2.0.1.35
OUI version       : 12.2.0.7.0
Log file location : /u02/app/oracle/product/19.3.0/db_home/cfgtoollogs/opatch/opatch2023-01-13_07-35-21AM_1.log
Lsinventory Output file location : /u02/app/oracle/product/19.3.0/db_home/cfgtoollogs/opatch/lsinv/lsinventory2023-01-13_07-35-21AM.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: noida
ARU platform id: 226
ARU platform description:: Linux x86-64
Installed Top-level Products (1):
Oracle Database 19c                                                  19.0.0.0.0
There are 1 products installed in this Oracle Home.
Interim patches (2) :
Patch  34133642     : applied on Fri Jan 13 00:17:16 IST 2023
Unique Patch ID:  24865470
Patch description:  "Database Release Update : 19.16.0.0.220719 (34133642)"
   Created on 14 Jul 2022, 16:09:56 hrs UTC
   Bugs fixed:

Verify at the Database Level

SQL> select patch_uid,patch_id,SOURCE_VERSION, TARGET_VERSION, action, status,action_time,description from dba_registry_sqlpatch;

Check Invalid Objects

SQL>COLUMN object_name FORMAT A30
SQL>SELECT owner,object_type,object_name,status FROM dba_objects
WHERE status = 'INVALID'
ORDER BY owner, object_type, object_name;
no rows selected
Last Updated: 5/28/2025, 10:54:58 AM