grant select sql
January 18, 2010 by Advisor
Filed under General Grant Information
ALTER USER command might be known to most of us. But it would be interesting to know that oracle provides an undocumented “identified by values” clause in this command. This clause can be very useful for DBA’s in some cases. Many times DBA needs to log into user’s account to make changes. Changes can be of any type like grant permission on user’s table to another user etc. for this example there could be two cases where this clause can helpful. First DBA doesn’t know the password of user and second he need to make changes to a set of users from a script, but, doesn’t want to include their passwords in the script itself.
Passwords of all the users are stored into dba_users table in encoded form. The encoded value can be used to generate an “alter user” command to reset the user’s password back to its original value. . The user’s password can be altered to a known value such as testPassword. Then jus log into the users account by connect userid/ testPassword, perform whatever changes you want to do and then run again generated “alter user command ” that will put password to its original value.
I will show a sample sql to generate the password change script for setting all users of database to a known password. In this example that known password is testPassword. We need one more script for resetting the passwords to original value. just run the pwdChange.sql to change the passwords to a known value and after doing your work run the pwdReset.sql to change the passwords to original values.
spool pwdChange.sql
select ‘alter user’ || username || ‘identified by testPassword;’ from dba_users;
spool off
spool pwdReset.sql
select ‘alter user’ || username ||’identified byvalues’”||password||”‘;’ from dba_users;
spo
|
|
Oracle Database 11g SQL $39.8 Write powerful SQL statements and PL/SQL programsLearn to access Oracle databases through SQL statements and construct PL/SQL programs with guidance from Oracle expert, Jason Price. Published by Oracle Press, Oracle Database 11g SQL explains how to retrieve and modify database information, use SQL Plus and SQL Developer, work with database objects, write PL/SQL programs, and much more. Inside, you`ll find in-depth coverage of the very latest SQL features and tools, performance optimization techniques, advanced queries, Java support, and XML. This book contains everything you need to master SQL.*Explore SQL Plus and SQL Developer *Use SQL SELECT, INSERT, UPDATE, and DELETE statements *Write PL/SQL programs *Create tables, sequences, indexes, views, and triggers *Write advanced queries containing complex analytical functions *Create database objects and collections to handle abstract data *Use large objects to handle multimedia files containing music and movies *Write Java programs to access an Oracle Database using JDBC *Tune your SQL statements to make them execute faster *Explore the XML capabilities of the Oracle Database *Master the very latest Oracle Database 11 *g *features, such as PIVOT and UNPIVOT, flashback archives, and much more |

