Postgres:在一个事务中截断和复制

Postgres: TRUNCATE and COPY in one transaction

我需要在 Postgres 9.4 中执行以下事务:

BEGIN TRANSACTION;
    TRUNCATE TestTable;
    COPY TestTable FROM '/DATAforTestTable' DELIMITER ',' CSV;
END TRANSACTION;

用户必须在执行事务时对 TestTable 中的 "old" 数据具有读取权限,而无需等待事务结束。可能吗?或者我必须通过复制和重命名表格来完成?

来自manual

TRUNCATE acquires an ACCESS EXCLUSIVE lock on each table it operates on, which blocks all other concurrent operations on the table.

使用delete

begin;
delete from t;