I’m creating a database with oracle and php for an assignment and i have to show the use of roles. i created a new role called employee and assigned it to a new user called employee1
CREATE ROLE read_only;
GRANT create session TO read_only;
GRANT select ON workson TO read_only;
GRANT select ON employee TO read_only;
GRANT select ON project TO read_only;
GRANT select ON department TO read_only;
CREATE ROLE employee;
GRANT read_only TO employee;
GRANT update ON employee TO employee;
GRANT insert ON workson TO employee;
Create user employee1 identified by qwerty1;
GRANT employee TO employee1;
Why does using any selects when connected as employee1 say there is no such table. select * from employee says there is no table. Did i form my roles wrong or something?
Your grants appear to be fine. Assuming that the
employee1user does not own theemployeetable, you would need to qualify the table name in yourSELECTwith the owner of the table. For example, if we’re talking about theemployeetable that is owned by thehruser, you’d need toIf you don’t want to have to qualify your table names, you have a couple of options. First, you can create synonyms. You can create a private synonym in the
employee1schema that applies only to theemployee1useror you can create a public synonym that applies to all users
The second option would be to set your
current_schemaafter connecting.If you have an appropriate synonym in place or if you’ve set the
current_schema, you don’t have to prefix the table name with the owner of the table.