mysql加载管道数据_利用管道迁移数据

磁盘空间不足的情况下,利用命名或者匿名管道迁移和导入数据;需要注意命名管道的权限问题。 0. Name PIP 0[pg@h1 ~]$ psql gtlions -ac select t3 tab,count(*) from t3 union all select t4,count(*) from t4;select t3 tab,count(*) from t3 union all se

磁盘空间不足的情况下,利用命名或者匿名管道迁移和导入数据;需要注意命名管道的权限问题。

0. Name PIP 0

[pg@h1 ~]$ psql gtlions -ac "select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;"

select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;

tab | count

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

t3 | 100

t4 | 0

(2 rows)

[pg@h1 ~]$ mknod syncpip p

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/sync'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/sync'"

ERROR: could not open file "/home/pg/sync" for reading: No such file or directory

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -ac "select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;"

select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;

tab | count

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

t3 | 100

t4 | 400

(2 rows)

1. Name PIP 1

[pg@h1 ~]$ rm -rf sync*

[pg@h1 ~]$ mkfifo syncpip

[pg@h1 ~]$ ll syncpip

prw-rw-r-- 1 pg pg 0 11月 6 09:15 syncpip

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -ac "select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;"

select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;

tab | count

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

t3 | 100

t4 | 800

(2 rows)

2. UnName PIP

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to stdout"|psql gtlions -p 5432 -c "copy t4 from stdin"

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to stdout"|psql gtlions -p 5432 -c "copy t4 from stdin"

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to stdout"|psql gtlions -p 5432 -c "copy t4 from stdin"

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to stdout"|psql gtlions -p 5432 -c "copy t4 from stdin"

[pg@h1 ~]$ psql gtlions -p 5432 -c "copy t3 to '/home/pg/syncpip'"|psql gtlions -p 5432 -c "copy t4 from '/home/pg/syncpip'"

COPY 100

[pg@h1 ~]$ psql gtlions -ac "select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;"

select 't3' tab,count(*) from t3 union all select 't4',count(*) from t4;

tab | count

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

t3 | 100

t4 | 1300

(2 rows)

-EOF-

f68f2add0b68e4f9810432fce46917b7.png

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值