473,408 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Pre-set default schema for new user

Hi,

When I create a new user in DB2, can I set the default schema to an
existing schema? The reason I want to do this is that I want to later
connect to db2 as this user and access tables WITHOUT the schema name
prefix. In addition to that, I want to use ADO.NET to connect as this
user and query tables in another schema without the prefix. (I use IBM
Ole DB Data provider in the connection string). The access is
currently set up properly. In other words, I can do everything I want
as long as I supply the prefix. I hope a "pre-set" can solve all my
problems. I know that you can do a "set current schema = xxx" after
you connect. But that is only good for that connection. Also, it is
difficult for me to make a change in the db access code which is a
third party software.
Thanks,

Jan 11 '06 #1
7 21273
AFAIK, at least in DB2 for LUW, there is no way to preset the default
schema at connection time (there is no such an option in CONNECT
statement). The default schema for user A is always A right after you
get connection to your database. You can use aliases in order to avoid
qualifying non-default schema objects with a schema name.

-Eugene.

Jan 11 '06 #2
gr*********@yahoo.com wrote:
Hi,

When I create a new user in DB2, can I set the default schema to an
existing schema?
First, you don't create users in DB2. Users are created at the operating
system level or by the means mandated by your specific security plugin.
The reason I want to do this is that I want to later
connect to db2 as this user and access tables WITHOUT the schema name
prefix.


You should remember that the schema name is an integral part of the
qualified table name. Personally, I consider it as good coding style to
always fully qualify the table name with the proper schema name. It just
helps to avoid any problems with determining the proper table.

But you can have a look at the CLI configuration. It allows you to set a
default schema that shall be used for a particular database. But that
default will only apply to CLI applications (and whichever interface builds
on that). I don't know if there are other mechanisms available for other
binding styles.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 11 '06 #3
In Oracle, there is such a thing such a a LOGON TRIGGER, that is, a
TRIGGER that fires when the user logs in. Is there an equivalent for
DB2? That would allow a SET SCHEMA statement to be run upon every
logion automatically.

B.

Jan 11 '06 #4
How do you use aliases to avoid qualifying non-default schema object
with a schema name?
Thanks,

Jan 11 '06 #5
I am connecting as user TS, that BTW has IMPLICIT_SCHEMA authority
granted (by default) to my db sandbox OAKL0 and do the following:

db2 => connect to oakl0 user ts
Enter current password for ts:

Database Connection Information

Database server = DB2/LINUX 8.2.1
SQL authorization ID = TS
Local database alias = OAKL0
db2 => values current schema

1

------------------------------

TS
1 record(s) selected.
db2 => create table x.t (i int) ----------------------> this creates
table and the schema X if the latter didn't exist
DB20000I The SQL command completed successfully.
db2 =>
db2 => list tables for schema ts

Table/View Schema Type Creation time
------------------------------- --------------- -----
--------------------------

0 record(s) selected.

db2 => list tables for schema x

Table/View Schema Type Creation time
------------------------------- --------------- -----
--------------------------
T X T
2006-01-11-13.27.23.025428

1 record(s) selected.
db2 => create alias t for x.t
DB20000I The SQL command completed successfully.
db2 =>
db2 => list tables for schema ts

Table/View Schema Type Creation time
------------------------------- --------------- -----
--------------------------
T TS A
2006-01-11-13.28.14.313375

1 record(s) selected.
db2 => insert into t values(1)
DB20000I The SQL command completed successfully.
db2 => select * from t

I
-----------
1

1 record(s) selected.

db2 => values current schema

1

----------------------------

TS
1 record(s) selected.

db2 =>
-Eugene

Jan 11 '06 #6
Brian Tkatch wrote:
In Oracle, there is such a thing such a a LOGON TRIGGER, that is, a
TRIGGER that fires when the user logs in. Is there an equivalent for
DB2? That would allow a SET SCHEMA statement to be run upon every
logion automatically.

B.

No log-on triggers in DB2. cli.ini is the standard answer to setting a
default schema. In many apps building up the connection isn't under end
user conbtrol anyway. So it can be easily wrapped.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 11 '06 #7
Thanks guys for the responses. I found a solution.

First of all, let me respond to the suggestions:
1. alias - Good workaround for the developer, not good for DBA. Shot
down by DBA.
2. including schema name as good coding practice - totally agree.
However, we are using a third party software that generates data
classes from the DB2 tables. Table names are hard-coded in these data
classes. Does anyone know a good code-generation software that allow
you to easily change the schema name?
3. cli.ini - Not sure how it works. Didn't see any mentioning of
user/pwd in this file. Does that mean the "current schema" setting
will be for anyone who logged on to DB2 database on this computer?
Also, what type of connection actually uses this file?

Now, my solution is to use the ibm.data.db2 which is the IBM's version
of DB2 .Net data provider. It allows you to set the currentschema in
the connection string. It is exactly what I wanted. The only thing is
that I have to modify the third-party source code (not the generated
data classes) so that it will use the ibm.data.db2 when it sees this
connection string. I was going to make this upgrade anyways.
(previoulsy we were using IBM's OleDB provider.) I read that the MS
Ole DB provider for DB2 takes a default schema parameter as well.
However, I don't really know how to setup the packages as required by
the connection string. The IBM's .Net provider connection string is
easy to set up and use.

Jan 16 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: GriffithsJ | last post by:
Hi I have been given some text that needs to be displayed on a web page. The text is pre-formatted (includes things like lists etc) and displays okay if I wrap it using the <pre/> tag. ...
7
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
8
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
7
by: Paul Connolly | last post by:
char *s = "Hello"; s = 'J'; puts(s); might print "Jello" in a pre-ANSI compiler - is the behaviour of this program undefined in any pre-ANSI compiler - or would it always have printed "Jello"...
12
by: Vadim Guchenko | last post by:
Hello. I'm using the following code: <html> <head> <style type="text/css"> pre {display: inline;} </style> </head>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.