Can i update the TABLE_OWNER [message #181512] |
Mon, 10 July 2006 06:27 |
sreehari
Messages: 101 Registered: May 2006
|
Senior Member |
|
|
Hi all
Can i update the TABLE_OWNER in user_synonyms to actual owner of
the schema..since all these synonyms were imported from different schema...so that i can query those synonyms..
Thanks in advance..
|
|
|
|
Re: Can i update the TABLE_OWNER [message #181516 is a reply to message #181514] |
Mon, 10 July 2006 06:43 |
sreehari
Messages: 101 Registered: May 2006
|
Senior Member |
|
|
Ok..but i will explain my scenario
I have a database schema I1RB which has synonyms based on the schema I1PB in the same database 'POETICDB'.
what i did is..i exported these two schemas in the same database
with the different schema names I1PB2,I1RB2..
Now..when i try to access the synonyms in I1RB2. i am getting the error like table/view does not exist..
becasue..the owner_name for those synonyms is still I1PB..
How can i reslove this issue..
Help on this is greatly appreciated...
Thank u
in the database POETICDB
|
|
|
Re: Can i update the TABLE_OWNER [message #181535 is a reply to message #181516] |
Mon, 10 July 2006 07:47 |
|
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
You exported two schemas and imported them individually.
So I1RB2 is an exact copy of I1RB, where the TABLE_OWNER is still point to I1PB.
So I1RB2 synonym has the table_owner as I1PB.
You need to recreate the synonym for I1RB2 ( so that it look into I1PB2, instead of I1PB).
Applying a similar example,
I am logged in as user TEST.
The synonym will show table_owner to be as SCOTT.
If i export and import TEST into Test2, and Scott into Another_scott, still test2 will be looking into SCOTT.
So You need to recreate the synonym.
To do so, i am extracting the DDL of the synonym in test.
This simple script create the ddl.
I will Spool the output. and run against test2.
Before that, i should also make sure
-test2 can query the object in another_scott ( grant select priv)
-drop the existing,invalid synonym
test@9i > show user
USER is "TEST"
test@9i > select synonym_name,table_owner,table_name from user_synonyms;
SYNONYM_NAME TABLE_OWNER TABLE_NAME
------------------------------ ------------------------------ ------------------------------
SYN_EMP SCOTT EMP
test@9i > get get_ddl_synonym.sql
1 set long 500000
2 set linesize 1000
3 SET HEAD off
4 set trimspool on
5 set verify off
6 column XXXX format a300
7 SELECT
8 replace(replace((DBMS_METADATA.GET_DDL('SYNONYM',D.SYNONYM_NAME))||';','"TEST".','"TEST2".'),'"SCOTT".','"ANOTHER_SCOTT".')
9 FROM user_synonyms D;
10* set head on;
test@9i > @get_ddl_synonym.sql
CREATE SYNONYM "TEST2"."SYN_EMP" FOR "ANOTHER_SCOTT"."EMP"
;
I used DBMS_METADATA.
You can use show=y option in import or whatever.
use Any GUI tool like toad to extract DDL and manually edit.
It is upto you.
[Updated on: Mon, 10 July 2006 07:48] Report message to a moderator
|
|
|
|