If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Do we have Synonyms in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-20-04, 00:58
lahiru lahiru is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
Do we have Synonyms in DB2

Hi all,

Do we have a mechanism to implement synonyms (like Oracle synonyms) in DB2.

thanks in advance,
Lahiru
Reply With Quote
  #2 (permalink)  
Old 05-20-04, 01:39
cgprakash cgprakash is offline
Registered User
 
Join Date: Feb 2002
Posts: 96
What is your OS??

For z/os, you can use SYNONYM.
For others, you can use ALIAS.

Take a look at SQL reference for syntax.(CREATE ALIAS ...)

Regards
Prakash
Reply With Quote
  #3 (permalink)  
Old 05-20-04, 03:18
lahiru lahiru is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
Thanx. I already looked into that but it does not serv my purpose. I actually need to access tables without prifixing the schema name for different users.
Reply With Quote
  #4 (permalink)  
Old 05-20-04, 03:41
sathyaram_s sathyaram_s is online now
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Two options :
1) Issue the SET SCHEMA in your program
2) Create an ALIAS for each user

The second one is a bit messy if the number of aliases increases (probably, true for ORACLE SYNONYMNs also)

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 05-20-04, 03:46
lahiru lahiru is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
Exclamation

the first solution is out any way. But the second one could u set the alias to users. To my knowledge it only gives another name to the table. For example After adding a alias I still had to access the table with <schemaname>.<aliasname>.

Cheers Lahiru
Reply With Quote
  #6 (permalink)  
Old 05-20-04, 04:11
sathyaram_s sathyaram_s is online now
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
CREATE TABLE USER1.TABLE1 ...

connect as USER2 :
SELECT * from TABLE1
Error: Table cannot be found .

As a privileged user :
CREATE ALIAS USER2.TABLE1 for USER1.TABLE1

Connect as USER2:
SELECT * from TABLE1
(Selects Rows)

Isn't this you want ?


Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 05-20-04, 04:38
lahiru lahiru is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
Thumbs up

Ah yes that what I want. Fine I was using the db2 client on Windows it didn't diaplay me the user i wanted. When I ran the the DDL as script with the user I want it fine now. Thanx....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On