【发布时间】:2021-09-15 13:19:55
【问题描述】:
我在协作表中创建了下面的视图
CREATE VIEW contents(
id,
title
)
AS
select
mytable.id as id,
mytable.title as title
from mytable
where mytable.owner = substring_index(user(), '@', 1);
有什么方法可以在 where 子句中检测 select, insert, update, delete 等视图内部的当前状态?
我希望有下面这样,不知道如何在 mysql/mariadb 中生成等价物
/* during select statement user can see all available data*/
if state == 'select' then
where 1 = 1 /* can see all data */
else
/* if state is update or delete user is allowed to modify or delete data which for which he/she is owner*/
where mytable.owner = substring_index(user(), '@', 1);
endif
MariaDB [test]> select * from mytable;
+----+-------------------+-------+
| id | title | owner |
+----+-------------------+-------+
| 1 | created by root | root |
| 4 | created by helen | helen |
| 6 | created by helen1 | helen |
| 7 | 123 | lina |
+----+-------------------+-------+
用户 helen 和 lina 在内容视图上拥有 SELECT, INSERT, UPDATE, DELETE 授权
- 同样用户
helen是普通用户如何授予创建new_database的权限,并继承helen在new_database中创建的任何新表的权限?我不想以管理员身份创建 helen。用户 helen 应该能够在她创建的数据库中创建任意数量的数据库和表。这是否可能?
new_database
table1
table2
.....
.....
tableN
【问题讨论】:
标签: mysql mariadb mysqladmin mariadb-10.5 mysqladministrator