postgresql 数据库schema 复制

------ 
--- 导出 
pg_dump -h *.*.*.*  -p 5432 -d you_databasename -n you_schema -f you_sqlfile.sql

---- 替换schema 名称
sed -i 's/^SET search_path = oldyou_schemaname, pg_catalog;$/SET search_path = newyou_schemaname, pg_catalog;/' you_sqlfile.sql

---- 没跑过
----sed -i 's/^oldyou_schemaname.$/newyou_schemaname./' you_sqlfile.sql

---- 导入指定数据库下
psql -d you_databasename -U postgres -f you_sqlfile.sql

  

posted on 2018-04-04 11:10  我叫宋  阅读(3400)  评论(0编辑  收藏  举报

导航