Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Last active October 25, 2020 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huacnlee/815737ab61cd8de8b08b1a27ab4c2102 to your computer and use it in GitHub Desktop.
Save huacnlee/815737ab61cd8de8b08b1a27ab4c2102 to your computer and use it in GitHub Desktop.
-- 创建名称为readonly的只读用户:
create user social with password '123456';
-- 然后把在public这个schema下现有的所有表的select权限赋给readobly,并执行下面的SQL命令:
grant select on select tables in schema public to social;
-- 上面的命令只是把现有的表的权限给了readonly用户,如果此时创建了表,readonly用户还是不能读,需要使用下面的SQL把所建表的select权限也给用户readonly:
alter default privileges in schema public grant select on tables to social;
----------------------- 全部权限
create user social with password '123456';
grant all ON ALL TABLES in schema public to social;
grant all ON ALL SEQUENCES in schema public to social;
alter default privileges in schema public grant all on tables to social;
@huacnlee
Copy link
Author

调整 Sequence 的起步

select * from notifications_id_seq;
alter sequence notifications_id_seq restart with 210000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment