Re: Create synonym

From: Brian Graham <GrahamB_at_psac.com>
Date: 1996/05/08
Message-ID: <4mqd1d$q6j_at_nic.ott.hookup.net>#1/1


>>I have 50 or so tables, now I want to create synonym for them,
>>same name as table name. How can I do this without manully one by one?

The solution is to build the create synonym script and then execute the second file. For example, try something like this:

spool syns2.sql                                                           
select 'spool syns.lis' from dual;                              
                                                                               
select 'create synonym &1'||'.'||table_name||' for XXXX'||'.'||table_name||';' 
from sys.dba_catalog                                                           
where owner='XXXX'                                                             
and table_type != 'SYNONYM'                                                    
/                                                                              
                                                                               
select 'commit;'                                                               
from dual                                                                      
/                                                                              
                                                                               
select 'spool off' from dual;                                                  
select 'exit' from dual;                                                       
                                                                               
spool off                                                                      
start syns2.sql                                                           

--
Brian
Received on Wed May 08 1996 - 00:00:00 CEST

Original text of this message