-2

I am new to Unix scripting...I have a list of userids for terminated employees. I want to write a script that will check these userids against my databases and disable/remove the user accounts associated to those userids. Doing this manually for each database and for each server will take an inordinate amount of time. I'll appreciate any help I can get as well as the constructive criticism.

Edit:

This is for Oracle RDBMS. Thanks for pointing that out @sticky bit Thanks @Verace

  • Why disable them? Why not remove them completely? – Vérace Aug 3 '18 at 0:32
  • "constructive criticism": Start by telling the DBMS you target at. – sticky bit Aug 3 '18 at 2:19
  • @sticky bit: You are right, I should have mentioned that this is for Oracle RDBMS. – Londi Tangu Aug 3 '18 at 13:36
0

For mysql you can run something like that from any shell:

mysql -u user -ppassword < /path/some_script.sql

Modern, more secure and more sophisticated way is to use the login-path:

mysql --login-path=root_on_server < /path/some_script.sql

where some_script.sql is a plain text file containing SQL statements separated by ;. Here you can GRANT/REVOKE/DROP privileges as you want.

Almost every other DBMS have the very similar CLI functionality so you can use that approach somehow.

  • Thanks Kondybas. I should have mentioned that this is for an Oracle RDBMS – Londi Tangu Aug 3 '18 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.