Postgresql - dump - 不生成文件的传输表数据

在两个数据库中,创建好相同的表,

执行命令导入:

psql -U postgres -h test01 -d test -c "COPY test01 to STDOUT" | psql -U postgres -h test02 -d test -c "COPY test02 from STDIN;"

[root@test01 ~]# ps -ef | grep psql

root 26745 25899 17 23:32 pts/0 00:00:08 psql -U postgres -h  -d test01 -c COPY test02 to STDOUT

root 26746 25899 20 23:32 pts/0 00:00:10 psql -U postgres -h test02 -d test -c COPY test02 from STDIN;

datid | datname | pid | usesysid | usename | application_name | client_addr | clien

t_hostname | client_port | backend_start | xact_start

| query_start | state_change | wait_event_type | wait_

event | state | backend_xid | backend_xmin | query | backend_type

-------+---------+-------+----------+----------+------------------+--------------+---------

---------------+-------------+-------------------------------+-----------------------------

--+-------------------------------+-------------------------------+-----------------+------

------+--------+-------------+--------------+-------------------------+----------------

16602 | test | 20455 | 10 | postgres | psql | 192.168.4.13 | test01

| 39188 | 2018-10-19 11:41:07.714961+08 | 2018-10-19 11:41:07.723336+0

8 | 2018-10-19 11:41:07.723336+08 | 2018-10-19 11:41:07.72334+08 | |

| active | 725 | 725 | COPY test02 from STDIN; | client backend

导入的过程中,并不会生成文件。导出的同时,就会相应的导入到目标端。由于是一个事务,所以导入时候并不会查到表内数据。但是可以看到表的大小一致在涨。

猜你喜欢

转载自blog.csdn.net/chuckchen1222/article/details/83180802