Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2010
    Posts
    4

    Unanswered: 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.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  3. #3
    Join Date
    Feb 2010
    Posts
    4
    Many thanks Andy. I'm quite clear now. Thanks once again.

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  5. #5
    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.

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •