I am using the following pg_dump and psql command lines through the terminal in order to transfer my table from one database to another.
pg_dump -U postgres -t public.table1 database1 | psql -U postgres -d database2
But the problem is that the table1 from the database1 is getting pasted into database2 with the same name, i.e. table1. I want to add the timestamp also into the name, something like table1_18_11_2014_20_45_30, in order to keep a track on when the transfer operation was taken place (in this case, at 20:45:30 hours on 18th Nov 2014). Any idea how to do this? Thx.
Cheers!
Best Answer
When you transfer the table you can alter the table name with
ALTER TABLE table RENAME TO table_datestamp
. I am not aware of automatic renaming tables while doing backup.Or you can modify sql dump file and then run the script after modifying it.