postgresql pg_dump

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011944141/article/details/83476803

man pg_dump

1.export table

pg_dump -h 127.0.0.1 -p 5432 -d db_test -U test -t public.test > test.sql

2.import table

drop table public.test
psql -h 127.0.0.1 -p 5432 -d db_test -U test -f test.sql

3.export database case

 pg_dump -h 127.0.0.1 -p 5432 -U test > db_test.sql

4.import database case

 drop database db_test;
 psql -h 127.0.0.1 -p 5432 -U test  -f db_test.sql

5.advice

  • View file size
\dt+ tablename 

When the data table is very small, you can use command.

 pg_dump -h 127.0.0.1 -p 5432 -d db_test -U test -t public.test |  psql -h 127.0.0.1 -p 5432 -d db_test -U test

猜你喜欢

转载自blog.csdn.net/u011944141/article/details/83476803