Sometimes I'd like to export just a single table and its dependencies, so I can do some experiments with it on a test database. Is there a way to do that, other than dumping the full db schema with
pg_dump and any table dependencies manually?
For example let's say I have a table
employees which has a single foreign key to
companies.id and uses a few custom enums or other types. Let's also assume
companies is self-contained, i.e. does not depend on anything else. So what I'd like to have is some way of dumping
employees, both schema and all (or a subset) of the data and automatically get the required type definitons, and the schema for
company as well as all referencered entries.
Is there a way to do this easily with
pg_dump or some other tool?