允许用户从表中选择 [英] Allowing a users to select from a table
问题描述
cis605确实存在emp表,我想向用户分配权限.有什么想法我做错了吗?
The emp table does exist for cis605 and I want to assign permissions to user. Any ideas to what I am doing wrong?
SQL> grant select on emp to user;
Grant succeeded.
SQL> connect user
Enter password:
Connected.
SQL> select * from emp;
select * from emp
*
ERROR at line 1:
ORA-00942: table or view does not exist
我也尝试过不同的方式
SQL> connect cis605
Enter password:
Connected.
SQL> grant select on system.emp to chap7;
grant select on system.emp to chap7
*
ERROR at line 1:
ORA-00942: table or view does not exist
这里我应该使用的语句
SQL> SELECT * from cis605.emp;
SQL> SELECT * from cis605.emp;
推荐答案
在第一种情况下,它不起作用,因为您需要:
In the first case it doesn't work because you need to either:
-
引用表名,包括它所在的模式.
Reference the table name including the schema it's in. i.e.
SELECT * FROM schema.EMP;
SELECT * FROM schema.EMP;
OR
2.创建一个[public]同义词,以便能够看到"表,而不必在每个SQL语句中都包括模式.
OR
2. Create a [public] synonym in order to be able to "see" the table without including the schema in every SQL statement.
在第二种情况下,您尝试引用该架构,但得到的是错误的架构. EMP表通常在SCOTT模式中找到,而不是SYSTEM中.尽管就您而言,也许您需要这样做:
In the second case you're trying to reference the schema, but getting the wrong one. The EMP table is typically found in the SCOTT schema, not SYSTEM. Though in your case maybe you need to do:
grant select on cis605.emp to chap7;
此外,拥有一个名为"USER"的用户也是一个坏主意-这是一个Oracle关键字. (尽管我想这可能只是出于示例目的)
Also, having a user called "USER" is a bad idea - it's an Oracle keyword. (Though I guess this may just be for the purposes of example)
这篇关于允许用户从表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!