473,385 Members | 1,707 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,385 software developers and data experts.

Grant global select/insert/update/delete to all users

I hope this isn't to simple of a question, but google/deja/DB2 doc have not
given me an answer yet.

In Oracle, we have the ability to grant select to all tables at the user
level.

In DB2, this doesn't seem to be possible. We can grant by going into the
control center, selecting the schema in the table section, and granting
access to all tables. But this won't help us when any new tables are
created.

Is there a way to do this? Or even granting access to Public would be
acceptable?

Thanks in advance!
Nate

--
Message posted via http://www.dbmonster.com
Nov 12 '05 #1
6 4720
Nate Jones via DBMonster.com wrote:
I hope this isn't to simple of a question, but google/deja/DB2 doc have not
given me an answer yet.

In Oracle, we have the ability to grant select to all tables at the user
level.

In DB2, this doesn't seem to be possible. We can grant by going into the
control center, selecting the schema in the table section, and granting
access to all tables. But this won't help us when any new tables are
created.

Is there a way to do this? Or even granting access to Public would be
acceptable?

Thanks in advance!
Nate

Seems like a pretty dangerous feature to me....
You can write a procedure that walke thorugh all tables in SYSCAT.TABLES
and GRANTs SELECT to PUBLIC.
Then all you need to do is call it "on ocasion".

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Here's a script that I use to do this...

../grant_user.sh <mydb> <username>

As follows:

# Generate grant statements for DB
## Generate and optionally execute GRANTS
# Unix platforms
# Provide the database name
# e.g. grant_user.sh database-name USER

.. /home/dbuser/sqllib/db2profile

DB=$1
USER=$2

#For script debugging
#if [ -f grant_user.tmp ]
# then rm grant_user.tmp
#fi

db2 -t -n +p<<enddb2>grant_user.tmp 2>&1

connect to $DB;

select distinct 'connect to $DB ;'
from sysibm.sysversions ;

--Generate GRANT statements for all user tables in a UDB database
select distinct substr('grant select, insert, update, delete on table
'||
rtrim(tbcreator)||'.'||rtrim(tbname)||

--Transaction Processing
' to user $USER ;',1,200)

from sysibm.syscolumns c, sysibm.systables t
where c.tbcreator not in ('SYSIBM','SYSSTAT', 'SYSCAT')
and c.tbcreator = t.creator
and c.tbname = t.name
and t.type = 'T'
and not c.tbname like'%EXCP'
order by 1 asc ;
enddb2
# Remove any lines with the word select in them:
#
cat grant_user.tmp | grep -v "select" | grep ";" > grant_user.out

cat grant_user.tmp | grep ";" > grant_user.out

rm grant_user.tmp

#Optionally execute it if you're happy with the generated output
db2 -tvf grant_user.out

Nov 12 '05 #3
Thanks for the replies.

Just so I'm clear: DB2 has no built-in method, whereby User A can create a
table, and User B automatically has select access to that table? (Aside
from User B having to have DBA privs, of course.)

--
Message posted via http://www.dbmonster.com
Nov 12 '05 #4
Nate Jones via DBMonster.com wrote:
Thanks for the replies.

Just so I'm clear: DB2 has no built-in method, whereby User A can create a
table, and User B automatically has select access to that table? (Aside
from User B having to have DBA privs, of course.)

Correct. First time I hear about such a request, actually

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5
Serge Rielau wrote:
Seems like a pretty dangerous feature to me....


Why do you say that ?

Nov 12 '05 #6
Mark Townsend wrote:
Serge Rielau wrote:
Seems like a pretty dangerous feature to me....

Why do you say that ?

The old philosophical question whether guns are dangerrous or people.
Personally(!) I think they are and so is _by_default_ giving every user
read access to all tables.
Add default userids, default passwords and SMB market and you got
yourself a truly open system :-)

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #7

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

Similar topics

0
by: Kubaton Lover | last post by:
I've got a MySQL database which contains users and their passwords. I have a PHP script that allows me to add new users and passwords to the database via a web form. What is the syntax to grant...
0
by: Charles Cantrell | last post by:
I have recently set up mySQL on a Mandrake release of Linux (Version 7 of Mandrake, I believe), using the binary 4.0.13 standard release. The set up and start up all were normal, as far as I...
0
by: Xerxes | last post by:
I am having a problem with accessing MySQL database from my PHP code. I tested accessing MySQL db locally and once things worked I created the same DB on my web hosting's server. No problem...
0
by: Xerxes | last post by:
I get an error message with this: GRANT SELECT , INSERT , UPDATE , DELETE ON sassisc.* TO sassisc@localhost IDENTIFIED BY 'dodge3' It comes back with an error message: SQL-query : GRANT...
6
by: Xerxes | last post by:
When I use the following GRANT statement GRANT SELECT , INSERT , UPDATE , DELETE ON sassisc.* TO sassisc@localhost IDENTIFIED BY 'dodge3' it came back with an error message: SQL-query : ...
7
by: Barbara Lindsey | last post by:
What kind of grant do you need to give a user so that they can have permission to do a "SELECT nextval(ID)" on a sequence? I granted the user SELECT,UPDATE,INSERT,DELETE on all the tables,...
5
by: Michael Fuhr | last post by:
I'd like to propose that certain GRANTs on a table cascade to the table's implicit sequences. In the current implementation (as of 7.4.5 and 8.0.0beta3), a table owner must typically issue GRANT...
8
by: carlospedr | last post by:
I have to insert data from about 30 tables into a single table (Users), to do so i used a cursor and a bit of dynamic sql, this should work fine if the tables have to do the select from had the...
1
by: sridhar4554 | last post by:
How to give a grant like select,update,insert on a single table i had tried with the command grant eg:GRANT SELECT,INSERT,UPDATE ON DTS_OUTBOX_QUEUE TO sanpapps@dap1 IDENTIFIED BY 'disable';...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.