将sql plus中的用户限制为表中的单个记录
我有一个员工表...此表有 5 列(empname、empgsm、empsal、empaddr、empdep) ...它有 10 条记录。我已经创建了10 个用户,相当于表中的 empnames 列。当用户使用他的 empname 又名用户名 & 登录时密码后,他只能看到表中他的记录。
例如,Smith 是一名员工,创建了一个名为 smith 的用户。当该用户处于会话中并键入“Select * from Employee_table”
时,他仅获取属于他,其中 empname 是 smith。
我如何使用权限来执行此操作?
I have one employee table...this table has 5 columns (empname, empgsm, empsal, empaddr, empdep) ...it has 10 records. I've created 10 users equivalent to the empnames column in the table. When a user logs in with his empname aka username & password, he will be able to see only his record from the table.
e.g. Smith is an employee, a user called smith was created. when this user is in session, and types "Select * from Employee_table"
he only gets the record that belongs to him, where empname is smith.
How do I do this using privileges?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的建议是在表上创建视图,其中包含基于当前用户名的条件,如下所示:
My sugestion is to create view on the table where include where condition based on curent user name some thing like this:
从标签 sqlplus 我猜你正在使用 Oracle。
在 Oracle 中,您可以使用细粒度访问控制(又称虚拟专用数据库)来完成此操作。它的工作原理是向任何 sql 语句添加 where 子句。
如果您有一个基于模式的应用程序,您还可以自己添加一个 where 子句(其中 username = user)。这可能不太安全,但对于许多用例来说已经足够了
当前登录用户的 Oracle 用户名可在变量“user”中找到。
From the tag sqlplus I guess you are using Oracle.
In Oracle you can do this using Fine Grained Access Control aka Virtual Private Database. It works by adding where clauses to any sql statement.
If you have an application based on the schema you can also add a where clause (where username = user) yourself. This is probably less secure but sufficient for many use cases
The Oracle user name of the currently logged on user is available in the variable 'user'.
如果我们谈论的是 Oracle,
GRANT
命令将允许用户SELECT
表,因此可以检索任何行。如果要限制用户对表的行级别访问,请使用 Oracle Label Security 等高级功能 1 2。如果您有严格的安全需求,建议您这样做,但我更喜欢使用另一种机制来验证用户,例如 LDAP。If we are talking about Oracle, the
GRANT
command will allow users toSELECT
a table, so can retrieve any row. If you want to restrict the user access to a table a row level, use advanced features as Oracle Label Security 1 2. This is recommended if you have heavy security needs, but I prefer to use another mechanism to validate users, like LDAP.