copy功能的用户权限

最近有客户想对数据库的用户权限做限制,需要用到copy的功能,不能确定其需要的权限,测试了一下:

highgo=# \c highgo testc
highgo=> select user;
 current_user 
--------------
 testc
(1 row)

highgo=> copy testcopyto to '/hgdata/20180140.csv' with csv;
ERROR:  42501: must be superuser to COPY to or from a file
HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.

testc为新建的普通用户,发现copy执行权限必须为超级用户。

[highgo@localhost ~]$ psql -h 10.254.23.240 -d highgo -U testc
Password for user testc: 
psql (4.1.1)

PSQL: Release 4.1.1
Connected to:
HighGo Database V4.1 Enterprise Edition Release 4.1.1 - 64-bit Production

Type "help" for help.

highgo=> select user;
 current_user 
--------------
 testc
(1 row)

highgo=> \dt
             List of relations
 Schema |      Name       | Type  | Owner  
--------+-----------------+-------+--------
 public | quiz_dictionary | table | highgo
 public | test            | table | highgo
 public | testcopyfrom    | table | highgo
 public | testcopyto      | table | testc
(4 rows)

highgo=> \copy testcopyto to '/hgdata/testc1.sql'
COPY 1

\copy 则是普通用户就可以使用。


BY  海无涯

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值