允许用户从表中选择
cis605 确实存在 emp 表,我想为用户分配权限。对我做错了什么有什么想法吗?
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> 的语句:从 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
I have also tried doing it differently
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
Heres the statement I should have been using
SQL> SELECT * from cis605.emp;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第一种情况下,它不起作用,因为您需要:
引用表名称,包括其所在的架构。即
SELECT * FROM schema.EMP;
或
2. 创建 [public] 同义词,以便能够“查看”表,而无需在每个 SQL 语句中包含架构。
在第二种情况下,您尝试引用架构,但得到了错误的架构。 EMP 表通常位于 SCOTT 模式中,而不是 SYSTEM 中。虽然在你的情况下,你可能需要这样做:
另外,拥有一个名为“USER”的用户是一个坏主意 - 它是一个 Oracle 关键字。 (虽然我猜这可能只是为了示例的目的)
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;
OR
2. Create a [public] synonym in order to be able to "see" the table without including the schema in every SQL statement.
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:
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)