I want to query DBA_USERs in order to identify sys and non-sys users/schemas. My client application however cannot connect as a SYS user and so I cannot query dba_users directly. I cannot grant privileges to the user as mentioned in answer -> gather dba_users information in Oracle database when connected as a user because it is a security flaw.
Investigating further, I found that all_users contains the same data as dba_users, however with less no. of columns (and less details).
So using this, I have come up with the below query -
SELECT distinct owner
FROM all_tables
where owner IN (SELECT username FROM all_users)
and tablespace_name not in ('SYSTEM','SYSAUX')
I am able to run this query as a normal or non-sys user.
Is this complete ? I would like to go ahead and use this query in my production code. Can anyone point out any potential issues or data I might be missing by using this query (by using all_users rather than dba_users). Thanks in advance.