These are queries to help assist with retrieving users inside of a SQL instance and the permissions that those users are assigned. These queries are designed to only read data and will not modify or create data inside of the database.
The following queries may assist you in determining your version of Oracle database if you are unsure. The version of the database will impact the queries you will need to run for "Users and Account Status", listed further below.
SELECT *
FROM v$versionSELECT *
FROM product_component_versionSELECT INSTANCE_NAME, HOST_NAME, VERSION, STATUS, LOGINS,
DATABASE_STATUS, INSTANCE_ROLE, CON_ID
FROM V$INSTANCEThe following query will show the password settings for all profiles in the database.
SELECT PROFILE, RESOURCE_NAME, LIMIT
FROM DBA_PROFILES
WHERE RESOURCE_TYPE = 'PASSWORD'
ORDER BY PROFILEThe following query has been designed to NOT pull password hashes out of the DBA_USERS table.
SELECT USERNAME, USER_ID, PROFILE, ACCOUNT_STATUS, LOCK_DATE,
EXPIRY_DATE, LAST_LOGIN, ORACLE_MAINTAINED
FROM DBA_USERSThe following query determines what System Privileges allow the user to perform system level activities.
SELECT GRANTEE, PRIVILEGE, ADMIN_OPTION
FROM DBA_SYS_PRIVSThe following query lists the roles granted to all users and roles in the database.
SELECT GRANTEE, GRANTED_ROLE, ADMIN_OPTION
FROM DBA_ROLE_PRIVSThe following query lists all roles that exist in the database.
SELECT ROLE, ROLE_ID, PASSWORD_REQUIRED, AUTHENTICATION_TYPE, ORACLE_MAINTAINED
FROM DBA_ROLESThe following query determines what users are granted SYSDBA, SYSOPER, SYSASM, SYSBACKUP, SYSDG, and SYSKM privileges.
SELECT USERNAME, SYSDBA, SYSOPER, SYSBACKUP, SYSKM, SYSDG, SYSASM
FROM V$PWFILE_USERS