【发布时间】:2018-01-12 14:27:34
【问题描述】:
我正在使用 MariaDB 10.2.6。当使用 root 用户运行语句时,它可以工作。但是,如果我与另一个用户(访问受限)一起尝试,它会失败,说我无权在动态生成的视图上执行 SELECT。我无法显式授予 SELECT 到该表,因为它不存在。
这是 WITH RECURSIVE 语句:
with recursive hierarchy (id, parent_department_id) as
(
SELECT id, parent_department_id
from department
where parent_company_id = 1
union all
select e.id, e.parent_department_id
from department e
join hierarchy h ON e.parent_department_id = h.id
)
select e.*
from hierarchy h
join department e ON e.id = h.id;
错误:
ERROR 1142 (42000): SELECT command denied to user 'aclapi'@'localhost' for table 'hierarchy'
当我以 root 身份登录并尝试将层次结构上的 SELECT 授予用户时:
ERROR 1146 (42S02): Table 'vblpso.hierarchy' doesn't exist
我应该如何授予权限以允许 WITH RECURSIVE 语句工作(不使用授予所有权限)?
【问题讨论】:
标签: mariadb common-table-expression