postgreSQL copy与\copy的区别
区别是:
比如当使用192.168.17.53连上192.168.17.52的数据库,使用copy tb1 to ‘/home/postgres/aa.txt’,该文件是存放在192.168.17.52上; 环境: 使用192.168.17.53登录到 192.168.17.52做演示: - 1. 先到192.168.17.52的/home/postgres下看看当前的文件 [root@localhost postgres]# pwd
/home/postgres
[root@localhost postgres]# ls
archive base dump pg_log pp.sql python script soft tb10.csv test.sql
[root@localhost postgres]#
- 2. 使用copy命令进行导出 [postgres@localhost root]$ psql -h 192.168.17.52 -U postgres postgres
could not change directory to "/root": Permission denied
psql (9.3.5)
Type "help" for help.
postgres=#
postgres=# copy bbs to '/home/postgres/bbs.sql';
COPY 31
使用copy的时候文件是保存在服务器端的,切换到192.168.17.52的/home/postgres下看看文件是否存在: [root@localhost postgres]# pwd
/home/postgres
[root@localhost postgres]# ls
archive base bbs.sql dump pg_log pp.sql python script soft tb10.csv test.sql
- 3. 使用copy命令进行复制: [postgres@localhost ~]$ pwd
/home/postgres
[postgres@localhost ~]$ ls
archive archive_failover base pg_log script trigger
postgres=# copy bbs to '/home/postgres/bbs.sql';
postgres=#
在192.168.17.53下在看一下: [postgres@localhost ~]$ pwd
/home/postgres
[postgres@localhost ~]$ ls
archive archive_failover base bbs.sql pg_log script trigger
使用copy是备份到客户端上。 恢复的时候也是一样,使用copy是从服务端寻找文件,使用copy是从客户端上寻找文件。 参考: http://francs3.blog.163.com/blog/static/40576727201412135333388/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |