Clear inactive sessions and stop n start pluggable database
Clear inactive sessions and stop n start pluggable database
Script To Clear inactive sessions, To restart pluggable database
[oracle@EXADB_SRVR tmp]$ cat /home/oracle/clear_inactive_sessions.sh
#!/bin/sh
export ORACLE_SID=ORCL1
export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1
export PATH=$ORACLE_HOME:$ORACLE_HOME/bin:$PATH:.
export TWO_TASK=ORAPDB1
sqlplus pdb_admin/******** << EOF
SET HEAD OFF
SET FEEDBACK OFF
spool /tmp/kill_inactive.sql
SELECT ‘ALTER SYSTEM KILL SESSION ”’ || SID || ‘,’ || SERIAL# || ‘,@’ || INST_ID || ”’;’ FROM GV\$SESSION WHERE USERNAME=’SCOTT’ AND STATUS in (‘INACTIVE’,’KILLED’);
spool off
EXIT
EOF
sqlplus pdb_admin/******** << EOF
SET ECHO ON
@/tmp/kill_inactive.sql
EXIT
EOF
export ORACLE_SID=ORCL1
export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1
export PATH=$ORACLE_HOME:$ORACLE_HOME/bin:$PATH:.
unset TWO_TASK
sqlplus ‘/as sysdba’ << eof
alter pluggable database ORAPDB1 close immediate instances=all;
alter pluggable database ORAPDB1 open read write instances=all;
exit
eof
rm /tmp/kill_inactive.sql