Trying to delete bunch of users using loop but failing [message #678675] |
Fri, 27 December 2019 03:36 |
|
a100
Messages: 34 Registered: March 2019
|
Member |
|
|
Hello all,
I am trying to delete bunch of users with their data from Oracle 12 using the following command:
BEGIN
FOR i IN (SELECT t.username
FROM dba_users t
WHERE t.username LIKE 'abc%'
AND t.username NOT LIKE 'abc_this_one_save') LOOP
EXECUTE IMMEDIATE 'DROP USER '|| i.username|| ' CASCADE';
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.Put_line(SQLERRM);
END;
but it looks like it doesn't work (I use DBeaver) - I test it with the following command:
SELECT t.username
FROM DBA_USERS t
WHERE t.username LIKE 'abc%'
order BY username;
and it still shows me all those users.
Can anyone tell me please what is wrong with it ?
[Updated on: Fri, 27 December 2019 03:53] Report message to a moderator
|
|
|
|
|
|
|
|
|