文章
问答
冒泡
postgresql批量修改表的owner

postgresql中,对表的权限控制比较严格,很多事情只有owner才有权限去做。所以我们尽量用onwer账户去操作。
但是有的时候我们需求去批量修改owner,比如导入的表结构。但是官方并没有提供比较好的命令。
我们可以用拼接sql的方式去完成这个命令。
1.查看有哪些表

select * from information_schema.tables where table_schema='public';



111.png

2.拼接sql

select 'ALTER TABLE ' || table_name || ' OWNER TO yourowner;' from information_schema.tables where table_schema='public';



222.png



3.报生成的sql 复制下来,执行即可

postgresql

关于作者

落雁沙
非典型码农
获得点赞
文章被阅读