我在协作表中创建了下面的视图
CREATE VIEW contents(
id,
title
)
AS
select
mytable.id as id,
mytable.title as title
from mytable
where mytable.owner = substring_index(user(), '@', 1);
有没有办法像select, insert, update, delete
where 子句一样检测视图内部的当前状态?
我希望像下面这样,不知道如何在 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 和 linaSELECT, INSERT, UPDATE, DELETE
对内容视图有授权
- 另外用户
helen
是普通用户如何授予创建 new_database 的权限,并继承 helen 在 new_database 中创建的任何新表的权限?我不想创建 helen 作为管理员。用户 helen 应该能够在她创建的数据库中创建任意数量的数据库和表。这是否可能?
new_database
table1
table2
.....
.....
tableN