首页 > 代码库 > postgresql数据库基础

postgresql数据库基础

创建只读账号

1.1以初始化账号登入

[root@localhost ~]# psql -U postgres

1.2创建用户

postgres=# create role develop with login password ‘123456‘;  

CREATE ROLE

postgres=# select usename from pg_user;

 usename  

----------

 postgres

 test

 develop

(3 rows)


1.3切换数据库

\c current_product

1.4赋予只读权限

current_product=# grant select on all tables in schema public to develop;

GRANT

1.5切换到develop用户

current_product=# \c - develop

You are now connected to database "current_product" as user "develop".

1.6检测是否拥有只读权限

current_product=> select * from test;    

 id 

----

(0 rows)



本文出自 “青春邓勇” 博客,请务必保留此出处http://dengyong.blog.51cto.com/8409869/1888850

postgresql数据库基础