DISCLAIMER: This question is similar to the stack overflow question here, but none of those answers work for my problem, as I will explain later.
I\'m t
The closest "miracle command" is something like
pg_dump -t tablename | sed -r 's/\btablename\b/tablename_copy/' | psql -f -
In particular, this takes care of creating the indexes after loading the table data.
But that doesn't reset the sequences; you will have to script that yourself.