The situation is I have two schemas: A and B. I have a restricted user that I need to give a privilege do SELECT queries in B schema and just it. How can I grant this user?
To create a user with the same privileges as the root user, use the following command, which grants global privileges to the user Janet connecting via localhost: mysql> GRANT ALL ON *. * TO 'janet'@'localhost' WITH GRANT OPTION; The WITH GRANT OPTION clause allows users to grant their privileges to other users.
You can't.
The best you can do is grant user a 'select' privilege each table in schema b.
this query will generate the commands you'll need:
select 'grant select on A.'||table_name||' to B;'
from dba_Tables
where owner = 'A';
The problem with this, is in the case you will want to add new table to A. then you'll have to grant the privilege on it separately. it will not do it automatically..
You may find you do not have access to dba_tables
,
The following block of code run in the owning schema (a) will grant permissions to all tables, to the user b
BEGIN
FOR t IN (SELECT * FROM user_tables)
LOOP
EXECUTE IMMEDIATE 'GRANT SELECT ON ' || t.table_name || ' TO b';
END LOOP;
END;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With