Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing Tables using getTables

0 views
Skip to first unread message

Scott Needham

unread,
Dec 17, 1997, 3:00:00 AM12/17/97
to

I was woundering if anyone could give me some advice

I create a table "T1" as user "A" , (in SYBASE )
when I use the DatabaseMetaData.getTables ( null,dbmd.getUserName(),
null,null )
( and logged in as user A ) It returns a list of tables User "A"
created; or should I say own

The question is, HOW ( in Sybase ) do I allow another user ( or grant
the privilige ) to other users ( or the general public)
to see this table through JDBC connection wtihout having to preceed the
the table name with the owners id

for Example :
In ORACLE you can create a public synonym; this would allow all users to
see the table
e.g CREATE PUBLIC SYNONYM T1 ON A.T!

In DB2 you can create an alias; this again would allow all users to see
the table
CREATE ALIAS T1 FOR A.T1

Any help in this matter would be gratly appreciated

Scott


David Clegg

unread,
Dec 17, 1997, 3:00:00 AM12/17/97
to Scott Needham

I'm no Sybase T/SQL expert, and there may well be other ways to
do this, but...
If you create the table as the database owner (dbo) then
unqualified table references are first checked with the
"current" user as owner, then as "dbo" as owner.
So if you do --
% login as dbo (sa by default)
create table t1(c1 int)
insert into t1 values (47)
grant select on t1 to PUBLIC
Then
% login as user_B
select * from t1
user_B's select will see the '47' because the query processor
will find dbo.t1

Same sort of thing is true for stored procedures created by
the dbo.

For maximum portability, you would want to write your queries
with fully qualified <owner>.<table> whenever you know who
owns the tables, or <database>.<schema>.<table> in the most
general case.

In your example, if user A had granted select to user B or to PUBLIC,
then user B could select from A.T1 - which you already know.

That is all I know,

dave

0 new messages