Be careful!!!
If you have INSERT/UPDATE/DELETE granted to public on all this tables , this grant overwrite any other SELECT grant to specified user. In the other words, any other grant are useless.
Roles are very useful, but will be only if you use the Informix version 11.XX , then you can use the buildin function sysdbopen() (look the manual for more information)
If you have the version previous 11.XX you will need change the program code to active the role manually.
Roles are like profiles where can be used by the user.
To define a role, is something like this (consult the Sql Syntax manual):
Code:
create table testA_table (code int);
create table testB_table (code int);
revoke all on testA_table from public;
revoke all on testB_table from public;
-- create roles
create role r_readonly;
create role r_readwrite;
-- define what user can use the role
grant r_readonly to user_cesar;
grant r_readonly to user_stan;
grant r_readwrite to user_stan;
-- define the table grants to role
grant select on testA_table to r_readonly;
grant select on testB_table to r_readonly;
grant select,insert,update,delete on testA_table to r_readwrite
grant select,insert,update,delete on testB_table to r_readwrite;
-- define the default role to user
grant default role r_readonly to user_stan;
-- if want to remove the default role:
-- revoke default role to user_stan
This way , to user xpto_stan ways start the session with select grants...
The user xpto_cesar need to active the role to use them:
Code:
-- when connect with xpto_cesar
select * from testA_table; --got error
set role r_readonly;
select * from testA_table; --works