How do I get all of the application-only or custom roles in an Oracle database? How do I get all of the application-only or custom roles in an Oracle database? oracle oracle

How do I get all of the application-only or custom roles in an Oracle database?


You can find the SQL behind the dba_roles view:

select * from dba_views where view_name = 'DBA_ROLES';

Here's the code on my system:

select name, decode(password, null,          'NO',                              'EXTERNAL',    'EXTERNAL',                              'GLOBAL',      'GLOBAL',                              'YES'),             decode(password, null,          'NONE',                              'EXTERNAL',    'EXTERNAL',                              'GLOBAL',      'GLOBAL',                              'APPLICATION', 'APPLICATION',                              'PASSWORD')from  user$where type# = 0 and name not in ('PUBLIC', '_NEXT_USER');

When I run select * from sys.user$ where type# = 0 order by ctime; I see a lot of views with a ctime at about the same time, several years ago. (The time is even before my database was created.) It's probably safe to assume that the old roles are system generated.

But that does not necessarily mean that the newest roles are all custom roles. The ctime might change after an upgrade or re-compile, or if you install new options.

It may be helpful to install a new instance and subtract whatever you see in that dba_roles.