Skip to Main Content
  • Questions
  • Need to get match and unmatch output for all users having profile and one role

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Nite.

Asked: May 18, 2025 - 3:22 am UTC

Last updated: May 19, 2025 - 7:22 am UTC

Version: 19

Viewed 100+ times

You Asked

Dear Tom,

I have a question. I have a profile say myprofile in dba_users view.
I'm selecting how many users having this myprofile

select username from dba_users where profile='MYPROFILE';
User1
User2
User3

Now I want to check whether all this 3 users have Connect role or not from dba_role_privs.

Suppose User1 and User2 are granted Connect role so how to check that in single query along with unmatched one which is User3.

Thanks
Nite

and Connor said...

select *
from (select username from dba_users where profile='MYPROFILE' ) profiles
left outer join
  dba_role_privs roles
on profiles.username = roles.grantee


should do the trick