Search Postgresql Archives

Re: How to synchronize tables in remote (production) and local databases in case if the structure of local database's table has been modified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 8, 2014 at 12:49 AM, Vitaly Isaev <visaev@xxxxxxxxxx> wrote:
> I am trying to figure out how to dump the contents of several selected
> tables from server in order to update the tables on development
> workstations. The biggest challenge is that the tables I'm trying to
> synchronize may be diverged (developers may add - but not delete - new
> fields to the tables through the Django ORM, while schema of the production
> database remains unchanged for a long time).

The COPY trick will probably help you. Note that I specify a column
list in the last COPY statement.

skonoplev@[local]:5432 ~=#
create table t (i integer);
CREATE TABLE

skonoplev@[local]:5432 ~=#
insert into t select * from generate_series(1, 5);
INSERT 0 5

skonoplev@[local]:5432 ~=#
copy t to '/tmp/t.dump';
COPY 5

skonoplev@[local]:5432 ~=#
truncate t;
TRUNCATE TABLE

skonoplev@[local]:5432 ~=#
alter table t add s text;
ALTER TABLE

skonoplev@[local]:5432 ~=#
copy t(i) from '/tmp/t.dump';
COPY 5

skonoplev@[local]:5432 ~=#
select * from t;
 i | s
---+---
 1 |
 2 |
 3 |
 4 |
 5 |
(5 rows)


-- 
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA

http://www.linkedin.com/in/grayhemp
+1 (415) 867-9984, +7 (499) 346-7196, +7 (988) 888-1979
gray.ru@xxxxxxxxx


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux