spool c:\segu.txt; SELECT 'CONNECT '||A.OWNER||'/'||A.OWNER||'@detalle ;' , 'Grant all on '||A.TABLE_NAME||' to '||A.GRANTEE||';' scrip FROM DBA_TAB_PRIVS A , DBA_ROLE_PRIVS B WHERE A.GRANTEE = B.GRANTEE and a.privilege = 'INSERT' and a.grantee = 'LLOBET_AUDITORIA'; connect sys/sysklm@detalle; grant all on Dbms_Alert to llobet_general; spool off declare cursor cur_objects is select object_type,object_name , owner from all_objects where -- object_type in('TABLE','VIEW','SEQUENCE','FUNCTION','PACKAGE','PROCEDURE') --and owner = 'LLOBET'; begin for rec_objects in cur_objects loop begin dbms_output.put_line(rec_objects.object_name); execute immediate('create public synonym ' || rec_objects.object_name || ' for ' || rec_objects.owner ||'.'||rec_objects.object_name ); if rec_objects.object_type in ('SEQUENCE','TABLE','VIEW') then execute immediate('grant all on ' || rec_objects.object_name || ' to llobet_general'); execute immediate('grant select on ' || rec_objects.object_name || ' to llobet_auditoria'); else execute immediate('grant execute on ' || rec_objects.object_name || ' to llobet_general'); execute immediate('grant execute on ' || rec_objects.object_name || ' to llobet_auditoria'); end if; exception when others then null; end; end loop; end; /