-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> I want to copy several columns of a source table from db1 to db2, and
> create the target table and rename the columns in the process.
Ignoring the db part for now, you can do the first part of your request
like this:
CREATE TABLE mytable2 AS SELECT mycol AS newcolname, id, foo AS foo2
FROM mytable WHERE id > 100;
Then pg_dump -t mytable2 and pg_restore, as the rest of this thread indicates.
Note that you'll lose any triggers, indexes, etc. so only use this if
all you really want is the table. Otherwise, it's probably easiest to
pg_dump the whole database and then drop/rename columns in the new
database.
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200508310915
https://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAkMVrhIACgkQvJuQZxSWSsg3ZwCgs5kG/5P+RFr315+v3ia0g+Tr
bAEAoKHfRhJYynxVqyo/U06WaSeDXh3s
=hZIK
-----END PGP SIGNATURE-----