I'm looking for a way to grant some right (say SELECT) on all tables of one user to some other user. Something like that:
GRANT SELECT ON Username1.* to Username2
Important condition is that I need not only granting the right to all existing tables, but I also want, that all tables that will be created by Username1 by default should be granted with correspondent right to Username2
What I've done is creation a an external script for choosing all tables created by Username1:
SELECT table_name FROM systable WHERE creator IN (SELECT user_id from sysuser WHERE username='Username1'))
and generating GRANT statements for every of them.
But than I need to execute that script as soon as new table is created. It is not really elegant to have that granting logic out of the database. I would prefer having kind of trigger within the database, but Sybase IQ does not support triggers.
Anybody have idea how to solve the problem in elegant manner?