Can anyone help me with the routine for the bulk deletion of users based on any criteria in the toad database.
Asked
Active
Viewed 54 times
0
-
Toad isn't a database. Toad is a tool for accessing the database. What database are you using? There are many flavors of Toad. – Michael S. Sep 14 '15 at 18:06
-
The database used is SQL. – SRINIVAS SANTHOSH Sep 15 '15 at 19:40
-
Can anyone also explain what is a routine regarding database? – SRINIVAS SANTHOSH Sep 15 '15 at 19:42
-
SQL is not a database. I don't know the answer to your question one way or the other, but it would help others if they know which database you're connecting to. There are many different versions of Toad for different databases, most of which support SQL. Is this Oracle, MySQL, etc.? You also haven't specified what kind of criteria you're trying to search for. – Michael S. Sep 22 '15 at 13:23
1 Answers
0
If you are on Oracle database this example will delete all users having a username starting with DELETEMEUSER. You can write a query to fetch users matching your criteria and delete using dynamic SQL.
DECLARE
CURSOR c1
IS
SELECT username
FROM all_users
WHERE username LIKE 'DELETEMEUSER%';
BEGIN
FOR c1_rec IN c1
LOOP
EXECUTE IMMEDIATE 'DROP USER ' || c1_rec.username || ' CASCADE';
END LOOP;
END;

Michael S.
- 1,771
- 15
- 20