English 中文(简体)
Oracle 授予角色
原标题:Granting roles on Oracle

我创建了一个数据库,上面有甲骨文和用于指派的phip,我必须展示角色的用途。 我创建了一个名为雇员的新角色,并将其分配给一个名为雇员的新用户1。

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;

为什么在连接为雇员1 时使用任何选择表示没有这样的表格。 选择 * 从雇员中选择 * 表示没有表格。 我的角色有错吗?

最佳回答

您的赠款似乎很好。 假设 < code> employee1 用户并不拥有 employee 表格, 您需要将您 < code> SELECT 中的表格名称与表格所有者定性为表格所有者。 例如, 如果我们在谈论由 用户拥有的 < code> employee 表格, 您需要将表格名称与表格所有者定性为“ code> SELECT employee 表格时, 您需要使用

SELECT *
  FROM hr.employee;

如果您不想限制您的表格名称, 您有几种选项。 首先, 您可以创建同名词。 您可以在 employee1 schema 中创建仅适用于 employee1 用户的私人同名词

CREATE SYNONYM employee
   FOR hr.employee;

或您可以创建适用于所有用户的公共同义词

CREATE PUBLIC SYNONYM employee
   FOR hr.employee;

第二个选项是在连接后设置您的 current_schema

ALTER SESSION SET current_schema=hr;

如果您已经设置了合适的同义词,或者您已经设置了 current_schema ,您不必在表格所有人中前缀表格名称。

问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...