1

I am able to get the script for table creation via pg_dump command in postgress sql similar way I need to generate for functions, SP's & views to export into SQL file via pg_dump.

Can you please help on this?

For a Table:

pg_dump -U postgres -d postgres  -t clientlocationregions > C:\clientlocationregions.sql

Thanks Mahesh

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
  • You might want to check following: https://stackoverflow.com/questions/13758003/how-to-take-backup-of-functions-only-in-postgres – Bo. Sep 08 '20 at 09:02
  • Does this answer your question? [How to take backup of functions only in Postgres](https://stackoverflow.com/questions/13758003/how-to-take-backup-of-functions-only-in-postgres) – D Kramer Sep 08 '20 at 15:02

1 Answers1

0

This will do:

pg_dump -Fc -s -n <schemaname> -f temp.dump <database name>
pg_restore -l temp.dump | grep FUNCTION > functionalist
pg_restore -L functionalist temp.dump > yourfunctions.sql
Nikhil S
  • 3,786
  • 4
  • 18
  • 32