Oracle Database Certified Associate (OCA) 1 minute read

Kita juga bisa menghapus usernya dengan perintah DROP USER tetapi usernya yang mau kita hapus sedang logged in maka tidak bisa di hapus atau akan muncul error log seperti berikut:

ORA-01940: cannot drop a user that is currently connected

Kita bisa tunggu sampai user tersebut logout, atau kita bisa terminate / kill sessionnya dengan perintah berikut:

Maka hasilnya seperti berikut:

sqlplus system/passwordnyaOracle18@XEPDB1

SQL*Plus: Release 18.0.0.0.0 - Production on Thu Mar 11 12:10:13 2021
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Last Successful login time: Thu Mar 11 2021 12:05:57 +00:00

Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> select SID, SERIAL#, USERNAME
from V$SESSION
where USERNAME = 'TOKO_ONLINE';  2    3

       SID    SERIAL# USERNAME
---------- ---------- --------------------
       791      51168 TOKO_ONLINE

SQL> alter system kill session '791, 51168';

System altered.

Berikut di sisi user toko_online

sqlplus toko_online/toko@XEPDB1

SQL*Plus: Release 18.0.0.0.0 - Production on Thu Mar 11 12:13:59 2021
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> select 1 + 1 from dual;
select 1 + 1 from dual
*
ERROR at line 1:
ORA-00028: your session has been killed

Setelah itu baru bisa di hapus: