允许用户从表中选择

发布于 2024-12-11 05:15:32 字数 704 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲影 2024-12-18 05:15:32

在第一种情况下,它不起作用,因为您需要:

  1. 引用表名称,包括其所在的架构。即

    SELECT * FROM schema.EMP;


2. 创建 [public] 同义词,以便能够“查看”表,而无需在每个 SQL 语句中包含架构。


在第二种情况下,您尝试引用架构,但得到了错误的架构。 EMP 表通常位于 SCOTT 模式中,而不是 SYSTEM 中。虽然在你的情况下,你可能需要这样做:

grant select on cis605.emp to chap7;

另外,拥有一个名为“USER”的用户是一个坏主意 - 它是一个 Oracle 关键字。 (虽然我猜这可能只是为了示例的目的)

In the first case it doesn't work because you need to either:

  1. 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:

grant select on cis605.emp to chap7;

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文