{"id":10919,"date":"2015-08-25T15:04:18","date_gmt":"2015-08-25T20:04:18","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=10919"},"modified":"2015-09-15T13:58:40","modified_gmt":"2015-09-15T18:58:40","slug":"oracle-role-grant-all-table-privileges-belong-to-one-user-to-another","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=10919","title":{"rendered":"Oracle Roles"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Role_Related_Views\">Role Related Views<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Database_Roles\">Database Roles<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_Database_Roles\">All Database Roles<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_System_Privileges\">All System Privileges<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_Column-specific_Privileges\">All Column-specific Privileges<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_Roles_Granted_to_Users_and_Other_Roles\">All Roles Granted to Users and Other Roles<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Role_Specific\">Role Specific<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_the_roles_granted_to_a_role\">All the roles granted to a role<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_the_system_privileges_granted_to_a_role\">All the system privileges granted to a role<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_the_object_privileges_granted_to_a_role\">All the object privileges granted to a role<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#User_Specific\">User Specific<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_roles_granted_to_a_user\">All roles granted to a user<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_object_privileges_granted_to_a_user\">All object privileges granted to a user<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Current_Session\">Current Session<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_system_privileges_in_current_session\">All system privileges in current session<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#All_roles_in_current_session\">All roles in current session<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Examples\">Examples<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Grant_ALL_Table_Privileges_Belong_to_One_User_to_Another\">Grant ALL Table Privileges Belong to One User to Another<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Role_Related_Views\"><h2>Role Related Views<\/h2><\/span>\n<p>* <a href=\"http:\/\/docs.oracle.com\/cd\/B10501_01\/server.920\/a96521\/privs.htm#15665\">Viewing Privilege and Role Information<\/a><\/p>\n<span id=\"Database_Roles\"><h2>Database Roles<\/h2><\/span>\n<span id=\"All_Database_Roles\"><h3>All Database Roles<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT * FROM DBA_ROLES;\r\n<\/pre>\n<span id=\"All_System_Privileges\"><h3>All System Privileges<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT * FROM DBA_SYS_PRIVS;\r\n<\/pre>\n<span id=\"All_Column-specific_Privileges\"><h3>All Column-specific Privileges<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT GRANTEE, TABLE_NAME, COLUMN_NAME, PRIVILEGE\r\n    FROM DBA_COL_PRIVS;\r\n<\/pre>\n<span id=\"All_Roles_Granted_to_Users_and_Other_Roles\"><h3>All Roles Granted to Users and Other Roles<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT * FROM DBA_ROLE_PRIVS;\r\n<\/pre>\n<span id=\"Role_Specific\"><h2>Role Specific<\/h2><\/span>\n<span id=\"All_the_roles_granted_to_a_role\"><h3>All the roles granted to a role<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT GRANTED_ROLE, ADMIN_OPTION\r\n   FROM ROLE_ROLE_PRIVS\r\n   WHERE ROLE = 'MY_ROLE';\r\n<\/pre>\n<span id=\"All_the_system_privileges_granted_to_a_role\"><h3>All the system privileges granted to a role<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT * FROM ROLE_SYS_PRIVS WHERE ROLE = 'MY_ROLE';\r\n<\/pre>\n<span id=\"All_the_object_privileges_granted_to_a_role\"><h3>All the object privileges granted to a role<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT TABLE_NAME, PRIVILEGE FROM ROLE_TAB_PRIVS\r\n    WHERE ROLE = 'MY_ROLE';\r\n<\/pre>\n<span id=\"User_Specific\"><h2>User Specific<\/h2><\/span>\n<span id=\"All_roles_granted_to_a_user\"><h3>All roles granted to a user<\/h3><\/span>\n<pre lang=\"sql\">\r\ndesc user_role_privs;\r\nselect * from user_role_privs where username='USER2';\r\n<\/pre>\n<span id=\"All_object_privileges_granted_to_a_user\"><h3>All object privileges granted to a user<\/h3><\/span>\n<p>* Not including column-specific privileges <\/p>\n<pre lang=\"sql\">\r\nSELECT TABLE_NAME, PRIVILEGE, GRANTABLE FROM DBA_TAB_PRIVS\r\n    WHERE GRANTEE = 'USER2';\r\n<\/pre>\n<span id=\"Current_Session\"><h2>Current Session<\/h2><\/span>\n<span id=\"All_system_privileges_in_current_session\"><h3>All system privileges in current session<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT * FROM SESSION_PRIVS;\r\n<\/pre>\n<span id=\"All_roles_in_current_session\"><h3>All roles in current session<\/h3><\/span>\n<pre lang=\"sql\">\r\nSELECT * FROM SESSION_ROLES;\r\n<\/pre>\n<span id=\"Examples\"><h2>Examples<\/h2><\/span>\n<span id=\"Grant_ALL_Table_Privileges_Belong_to_One_User_to_Another\"><h3>Grant ALL Table Privileges Belong to One User to Another<\/h3><\/span>\n<pre lang=\"sql\">\r\nCREATE ROLE MY_ROLE;\r\nGRANT MY_ROLE TO USER2;\r\n\r\nBEGIN\r\n   FOR tbl IN (SELECT table_name FROM all_tables WHERE owner = 'USER1') LOOP\r\n      dbms_output.put_line('Granting table: ' || tbl.table_name || ' to MY_ROLE');\r\n      execute IMMEDIATE 'GRANT ALL ON USER1.'||tbl.table_name||' TO MY_ROLE';\r\n   END LOOP;\r\nEND;\r\n<\/pre>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"http:\/\/docs.oracle.com\/cd\/B10501_01\/server.920\/a96521\/privs.htm\">Managing User Privileges and Roles<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Role Related Views * Viewing Privilege and Role Information Database Roles All Database Roles SELECT * FROM DBA_ROLES; All System Privileges SELECT * FROM DBA_SYS_PRIVS; All Column-specific Privileges SELECT GRANTEE, TABLE_NAME, COLUMN_NAME, PRIVILEGE FROM DBA_COL_PRIVS; All Roles Granted to Users &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=10919\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[35,47],"tags":[],"class_list":["post-10919","post","type-post","status-publish","format-standard","hentry","category-oracle","category-sql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2Q7","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/10919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10919"}],"version-history":[{"count":4,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/10919\/revisions"}],"predecessor-version":[{"id":10941,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/10919\/revisions\/10941"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}