使用escape自定义逃逸符
最近更新时间: 2025-02-18 16:02:00
postgres=# copy t to '/data/pgxz/t.txt' with quote '%' csv;
COPY 3
postgres=# \! cat /data/pgxz/t.txt
1,TDSQL PG,,7
2,%pg'", xc%%%,2017-10-28 18:24:05.643102,3
3,pgxz,2017-10-28 18:24:05.645691,
#不指定escape逃逸符,默认和QUOTE值一样
postgres=# copy t to '/data/pgxz/t.txt' with quote '%' escape '@' csv;
COPY 3
postgres=# \! cat /data/pgxz/t.txt
1,TDSQL PG,,7
2,%pg'", xc@%%,2017-10-28 18:24:05.643102,3
3,pgxz,2017-10-28 18:24:05.645691,
#指定逃逸符为’@’
postgres=# copy t to '/data/pgxz/t.txt' with quote '%' escape '@@' csv;
ERROR: COPY escape must be a single one-byte character
#这必须是一个单一的单字节字符。
postgres=# copy t to '/data/pgxz/t.txt' with quote '%' escape '@';
ERROR: COPY quote available only in CSV mode