Fastest way to do insert in a table A with same structure of a table B:
INSERT INTO A
SELECT * FROM B
I can't rename table because in table A there are indexes that when query is executed it's impossible to know without read catalog and create a dynamic script to modify table B to be equal to table A. Also, on table A there are on it some views than it's difficult to delete.
I can't use COPY
command to make a COPY TO and next a COPY FROM because database user haven't permission on file and directory.
Is there a way to do a COPY A FROM (SELECT * FROM B)
?
PostgreSQL version 9.2.
INSERT
?copy
. In fact, Yang's deleted answer (create table Aexample as select * from Bexample
) was actually pretty good in this respect, since it'll give you a raw table without any of the stuff that might slow you down.