Reputation: 683
I need to execute following transaction in Postgres 9.4:
BEGIN TRANSACTION;
TRUNCATE TestTable;
COPY TestTable FROM '/DATAforTestTable' DELIMITER ',' CSV;
END TRANSACTION;
Users must have read access to "old" data in TestTable on time of executing the transaction without waiting of tansaction end. Is it possible? Or I must do it via coping and renaming tables?
Upvotes: 2
Views: 4627
Reputation: 125414
From the manual:
TRUNCATE acquires an ACCESS EXCLUSIVE lock on each table it operates on, which blocks all other concurrent operations on the table.
Use delete
begin;
delete from t;
Upvotes: 5