In the Oracle database, multiple users are created. How do we view all users in the current database? This article will introduce how to view Oracle users.
To view existing users in Oracle, you can use the following script:
SELECT USERNAME FROM DBA_USERS;
This will return the usernames of all users.
Users are allocated to table spaces in Oracle. We can view the table space where the user is located through the following script:
SELECT USERNAME, DEFAULT_TABLESPACE FROM DBA_USERS;
This script will return the usernames of all users and the default tablespaces where they are located.
In Oracle, users can be assigned to different roles, and these roles can be used to grant users different permissions. We can view all users and their roles using the following script:
SELECT GRANTED_ROLE, USERNAME FROM DBA_ROLE_PRIVS;
This script will return each username and the name of the role they were granted.
We can check the permissions a user has through the following script:
SELECT DISTINCT PRIVILEGE, USERNAME FROM DBA_SYS_PRIVS;
This script will return all users and the systems they own permissions.
If a user is locked, he will not be able to access the database. We can use the following script to query locked users:
SELECT USERNAME FROM DBA_USERS WHERE ACCOUNT_STATUS LIKE '%LOCKED%';
This script will return the usernames of all users whose account status is locked.
For security reasons, we should not directly view the user password. If we need to reset the password, we can use the following script:
ALTER USER [username] IDENTIFIED BY [new_password];
This script will change the user password. The username and new password need to be replaced with the required values.
To sum up, the above are several ways to view Oracle users. Whether you are viewing users, table spaces, roles, permissions or lock status, you can quickly view Oracle user data through the above methods.
The above is the detailed content of How to view Oracle users? A brief analysis of various methods. For more information, please follow other related articles on the PHP Chinese website!