I have a group of students that I want to grant student privilege's to a specific database set up in oracle. Is there a way to do this at once or I can only do it individually?
I have an excel spreadsheet with student numbers and here is the sql code I am using to add them individually so far
CREATE USER S56879 IDENTIFIED BY student
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp
QUOTA 100M ON users;
GRANT STUDENTROLE TO S56879;
You can import the Excel data into a table and then use dynamic SQL; something like:
begin
for s in (select student_num from someTable) loop
execute immediate 'CREATE USER ' || s.student_num || ' IDENTIFIED BY ...';
execute immediate 'GRANT STUDENTROLE TO ' || s.student_num;
end loop;
end;