I want to drop all users who have 'WIN' at the start of their name (for example, 'WIN$DOWS'). Is it possible to write something like like the follownig?
drop user where name like 'WIN%'
The DROP USER statement doesn't support a WHERE clause, much less LIKE and wildcarding.
You need to fetch a list of users from DBA_USERS that match, and iterate over that list:
--Bye Users!
FOR i IN (SELECT t.username
FROM DBA_USERS t
WHERE t.username LIKE 'WIN%') LOOP
EXECUTE IMMEDIATE 'drop user '|| i.username ||'';
END LOOP;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With