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