Hi I am currently using postgresql and deleting some of the tables for testing purpose and I want to take backup of schema. can any one let me know how to do that ?


1 Answer 1


You export only schema without data using pg_dump in psql [terminal]:

pg_dump -U postgres -s databasename > backup.sql

or with Pgadmin4

  1. Go to Tool -> Backup and select only schema in the Dump option.

Screenshot of Backup

  • 1
    it is not clear from the answer, but with pg_dump the parameter you need is -s in order to dump schema only.
    – mastazi
    Jun 27, 2021 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.