ALTER USER IDENTIFIED BY VALUES
One problem that occasionally pops up is that a DBA needs to recreate a user with a password that he does not know. This happened to me when I had to create a schema with the same password on a development database. After I set an initial password for the developer, he exclaimed that he wanted the same password that he had for the schema X, but he did not want to tell me the password (don’t ask here, that’s a completely other story).
One way to do this is to use ALTER USER ... IDENTIFIED BY VALUES
. Using the excellent article on the ALTER USER commands from Laurent Schneider, we can generate a dynamic SQL query to set a password without knowing the password itself!
Here is the query to read the password from sys.user$
from Laurents article: