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 > db2 syntax to get entries from table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-10, 07:40
raufjawaid raufjawaid is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
db2 syntax to get entries from table

Hello guys,

I would really appreciate if some one could help me on my problem.

I am a beginner user of db2. What I want to do is, lets say a user 'user1' creates a database 'db1' and a table 'mytable' in this database. Now I want another user 'user2' to be able to access and modify 'mytable' created by 'user1'.

What should be the syntax, this is what I am trying.

select * from mytable (this is giving error)

select * from user1.mytable (this works fine)

but I want to use the first command. I do not want to mention the schema name in the above command. Is this possible, if yes what should be the configuration.

I will be really thankful if some one can help me on this.
Reply With Quote
  #2 (permalink)  
Old 02-09-10, 08:19
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
When you use an unqualified table name in a query (no schema name), DB2 will supply one for you. It defaults, I believe, to the value of CURRENT USER. If you would like it to be different, you can issue "SET CURRENT SCHEMA <schema name>".

Andy
Reply With Quote
  #3 (permalink)  
Old 02-09-10, 08:41
raufjawaid raufjawaid is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Many thanks Andy. I'm quite clear now. Thanks once again.
Reply With Quote
  #4 (permalink)  
Old 02-09-10, 09:06
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Depending on the remote client you are using, you may be able to define the default schema name in your jdbc connection string.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 02-09-10, 11:44
raufjawaid raufjawaid is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks Marcus_A. Would you mind guiding me. I am using hibernate. What hibernate property should I set for changing schema.
Reply With Quote
  #6 (permalink)  
Old 02-09-10, 13:31
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Quote:
Originally Posted by raufjawaid View Post
Thanks Marcus_A. Would you mind guiding me. I am using hibernate. What hibernate property should I set for changing schema.
I don't think that would normally be done in Hibernate. It would be done in the DB2 connection string in your application server (jboss, WebSphere, etc.). The default schema name can be defined in a jdbc connection string.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
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