Run in source database:
SET pages 0SPOOL privs.sql-- create rolesSELECT 'create role ' || ROLE || ';'FROM dba_roles;-- grant rolesSELECT 'grant '|| granted_role|| ' to '|| grantee|| DECODE (admin_option, 'YES', ' with admin option;', ';')FROM dba_role_privs;-- grant system privilegesSELECT 'grant '|| PRIVILEGE|| ' to '|| grantee|| DECODE (admin_option, 'YES', ' with admin option;', ';')FROM dba_sys_privs;-- grant object privilegesBREAK on myGrantorCOL myCommand newlineSELECT 'prompt ' || grantor || 'connect ' || grantor mygrantor,'grant '|| PRIVILEGE|| ' on '|| owner|| '.'|| table_name|| ' to '|| grantee|| DECODE (grantable, 'YES', ' with grant option;', ';') mycommandFROM dba_tab_privsORDER BY grantor;-- grant column privilegesSELECT 'connect ' || grantor mygrantor,'grant '|| PRIVILEGE|| ' on '|| owner|| '.'|| table_name|| '('|| column_name|| ')'|| ' to '|| grantee|| DECODE (grantable, 'YES', ' with grant option;', ';') mycommandFROM dba_col_privsORDER BY grantor;QUITThis will generate spool file "privs.sql" in current working directory. Remove references to usersfrom privs.sql that does not exist in target database.connect as user with dba role on target database and run script privs.sql Object privileges can be granted by "object owner" only.Script will ask for password of each user who granted object privilege.
No comments:
Post a Comment