首页 > 其他 > 详细

postgres基础知识

时间:2017-05-27 13:12:17      阅读:338      评论:0      收藏:0      [点我收藏+]

postgres是连接到具体的库:
   ./psql -U postgres  不指定库,默认就是用户名的同名库
   ./psql -d chat -U postgres  指定chat库
   
postgres登录权限配置文件是在数据目录下的pg_hba.conf     



\du: 查看用户
\dt: 查看表
\dn:查看schema
\c: 切换连接 如 \c postgres postgres 使用postgres用户连接到postgres数据库
\d: 查看数据库对象
\l:查看数据库

批量给某个用户授权示例
1. 管理员登录: ./psql  -U postgres

2. 创建用户: create user chat with password  ‘chatpasswd‘

3. 给用户授权:
   1. 先登录到需要授权的库下
    ./psql -d chat -U postgres

   2. 查看schema类型
    \d

   3. 根据schema授权
    grant all privileges on all tables in schema public to chat;
    
    grant usage,select on all sequences in shcema public to chat;

postgres基础知识

原文:http://www.cnblogs.com/zhaojonjon/p/6912361.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!