先进入psql

切换到目标数据库

\c mydb

对于老表

grant usage on schema public to $read_only_user;
grant select on all tables in schema public to $read_only_user;

设置默认,对于未创建的表直接默认赋予只读权限

alter default privileges for user $db_owner in schema public grant select on tables to $read_only_user;

pubic这个schema是默认的schema

阿里云得创建superuser,然后赋予default_transaction_read_only属性,不然貌似不行

select usename,useconfig from pg_user where usename='xxx';
alter role xxx set default_transaction_read_only=true;
select usename,useconfig from pg_user where usename='xxx';

推荐用这个,简单方便

测试建表语句

create table t2 ( id serial, name varchar() );

最新文章

  1. AngularJS SPA Template For Visual Studio
  2. PHP character garbled
  3. Ajax学习笔记1之第一个Ajax应用程序
  4. 对URL编码
  5. C#窗体 自定义控件
  6. input 标签实现带提示文字的输入框
  7. Unity3D脚本语言UnityScript初探
  8. gym101090 I Painting the natural numbers
  9. 【转】c语言入门教程 / c语言入门经典书籍
  10. 生产项目加入到SVN版本控制
  11. strlen与sizeof有什么区别?
  12. Charts 常见使用类型实例
  13. HBase写数据
  14. 第22章 使用外部身份提供商登录 - Identity Server 4 中文文档(v1.0.0)
  15. 小tips:JS中typeof与instanceof用法
  16. 老男孩python学习自修【第二天】字符串用法
  17. http转发
  18. checkbox简单例子
  19. 02 http,servlet,servletconfig,HttpServletRequest ,HttpServletResponse
  20. this与$scope

热门文章

  1. Sql 2000丢失sa 密码,重置sa密码
  2. TCP三次握手连接与四次握手断开
  3. html5的改进与沿革
  4. leetcode 107 Binary Tree Level Order Traversal II ----- java
  5. JAVA导入包
  6. 【NOIP2013】【P1441】花匠
  7. springMvc源码学习之:spirngMvc的拦截器使用
  8. eclipse使用jetty插件出现内存溢出解决方案
  9. MySQL-python模块
  10. Java classes and class loading