2017-12-29 12 views
0

psql pipe 명령을 사용하여 Postgres의 한 데이터베이스에서 다른 데이터베이스로 테이블을 복사했습니다. 잘 작동합니다. 그러나 새 데이터베이스의 특정 스키마에 테이블을 복사해야합니다. 나는 문서 (스키마 이름을 지정하기 위해 -n 옵션 사용)를 통과했지만 작동하지 않습니다.psql pipe 명령을 사용하여 postgres의 특정 스키마에 삽입하는 방법

명령 :

pg_dump -U postgres -h localhost -p 1212 -d dbname -t tablename -Ft | pg_restore -U postgres -h localhost -p 1213 -d dbname -n schemaname 

답변

0

pg_dump|pg_restore 순서로 할 수 없습니다. 당신은 내가 이런 식으로하는 것이 그것을 할

0

복원 DB에 alter table t set schema s; 필요 : 해당 정규 표현식으로

pg_dump -U postgres -h localhost -p 1212 -d dbname -t tablename | sed "sed/oldschemaname/newschemaname/" | psql -U postgres -h localhost -p 1213 -d dbname -n schemaname