Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Sagi.

Asked: March 05, 2002 - 10:51 am UTC

Last updated: July 28, 2005 - 3:41 pm UTC

Version: 8.1.x

Viewed 10K+ times! This question is

You Asked

Q1.
I am writing some scripts for doing some automation. In the script it connects to various users. So the problem is I can not hard core the password because down the line the passwords keep changing. Therefore the easiest way is to pick the encrypted one from DBA_USERS, which enables to get the Current Password.

So can we connect using the encrypted passwords. something like this

VAR encrypted_password

SELECT password INTO :encrypted_password FROM dba_users
WHERE username='SCOTT' ;

CONN scott/<encrypted_password>@hoststring


Q2.
Can we grant Object Privileges to Users on other Database? If Yes could you give me an example Please.

SID-ORCL
=======
RND

SID-ORACLE
==========
SCOTT
CONN SCOTT/TIGER
GRANT SELECT ON EMP TO RND@DBLINK_TO_ORCL ;


Regards,
Krishna.

and Tom said...

q1) see
</code> http://asktom.oracle.com/Misc/su.html <code>


q2) No, you need to be on the SOURCE database to grant on the remote object -- you are going to be updating that remote databases data dictionary and DDL over dblinks is not supported.

You CAN do this:

create view emp_view as select * from rnd@dblink_to_orcl;

grant select on emp_view to "whomever";



Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

cool script

Tianhua Wu, March 05, 2002 - 1:24 pm UTC

I love the su.sql and modify a little bit so that it will work when connect to a remote database.

-- export SQLPATH
SET VERIFY OFF
SET FEEDBACK OFF

whenever sqlerror exit
column password new_value pw
column instance_name new_value iname

declare
l_passwd varchar2(45);
begin
select password into l_passwd
from sys.dba_users
where username = upper('&1');
end;
/

select password
from sys.dba_users
where username = upper( '&1' )
/

select instance_name
from sys.v_$instance
/

alter user &1 identified by Hello;
connect &1/hello@&iname

alter user &1 identified by values '&pw';

whenever sqlerror continue
@login
SET VERIFY ON
SET FEEDBACK ON




sagi, March 06, 2002 - 12:09 pm UTC

Your ans is good but does not solve my problem.

Actually I am working on discoverer. I have 3 DBs (Databases). User1 and User2 are on DB1 AND DB2.

On the 3rd DB, I have:
==> DB Links to DB1 and DB2 pointing to User1 and User2
==>Three users DISC, X and Y.
==> DISC is having the EUL and Business areas say User1BusinessArea and User2BusinessArea. Access on User1BusinessArea is given to user X and access on User2BusinessArea is given to user Y.

Down the Line, I move:
==>User2 from DB2 to DB1
==>DISC, X, Y from DB3 to DB1

So now we have DB1 with all the users. If I try to open the Workbooks that were created earlier it would give me error because the DB link is hard-cored in the EUL Tables.

So how do i solve this problem?

Would be greatful if you could give me the solution.

Regards,


Tom Kyte
March 06, 2002 - 12:46 pm UTC

well, that problem is a *TAD* different from the other "problem" isn't it? rhetorical question there -- the answer is "YES, YES it is."

You'll want to contact support for assistance. I'm not that up on discovers EUL personally.

Reference does not work

reader, July 28, 2005 - 2:35 pm UTC

The reference </code> http://asktom.oracle.com/~tkyte/Misc/su.html <code>does not work. As usual the answer is very good and useful.

Tom Kyte
July 28, 2005 - 3:41 pm UTC

change osi to asktom in the URL...

I modified it above