table manipulation
От | Mr. Dan |
---|---|
Тема | table manipulation |
Дата | |
Msg-id | BAY102-F311A5CC2849C98E7BB954CD1F50@phx.gbl обсуждение исходный текст |
Список | pgsql-admin |
I have a large database (20 Gb) on PostgreSQL 8.1.0 where I need to make a copy of the structure and also copy the data from a few of the tables (approximately 40 out of 140, resulting database is approximately 10 Mb) which have dependencies on each other. The problem I am having is finding the best way to go about this using an automated script. There were a few options I could think of: 1) copy the whole large database and then truncate the tables I didn't need (the tables I need have a specific naming scheme). This seems wasteful and can take up to 5 hours to do. 2) copy the schema from the database and then dump just the tables I want and restore them on the new database. The problem I run into here is the inter-dependencies between some of the tables makes this hard to do programmatically (I could hard code the order list of which tables to fill, but then what happens when we add more tables?) Are there other approaches that I'm missing here? I need to do this across several databases which have basically the same structures and naming schemes but the dependencies on all of the databases are different. I'm trying to come up with a generic solution that I can use for all of the databases without having to maintain the dependencies for each.
В списке pgsql-admin по дате отправления: