sql - 如何在 Postgres 中授予以 parcel 开头的表的权限?
问题描述
GRANT UPDATE
ON (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE 'parcel%')
TO police;
解决方案
GRANT
只接受固定的表名(或表列表)。您想要的需要动态 SQL,即动态构建语句并在匿名块中执行它。
考虑:
do
$$
begin
execute (
select
'grant all on table '
|| string_agg (format('%I.%I', table_schema, table_name), ', ')
|| ' to police'
from information_schema.tables
where table_name like 'parcel%'
) ;
end
$$;
推荐阅读
- flutter - 除非我弹出屏幕并重新加载,否则无状态小部件不显示提供程序数据
- sql - 在Oracle SQL中按字符数拆分字符串
- python - 如何为其他方法封装类方法
- angular - 有没有办法从组件中的 db 值添加角度指令?
- java - JNI - 如何获取 Double.toString() 方法以将 jdouble 转换为 jstring
- node.js - 在 AWS ec2 实例上部署 Node Express 应用程序和 php 应用程序的最佳实践
- php - 从对象 php laravel 获取数据
- git - Git:制作一个由当前分支的更改组成的 PR,该更改取决于另一个分支的更改
- transactions - Spring重试期间如何根据线程增加Atomikos默认jta超时
- django - 自定义的 django all-auth 表单未提交