Friday, August 14, 2015

pgAdmin

Copy just the schema of a database: do Backup, with any format other than Plain (it requires pgsql to import it) and on the Option tab page select Schema Only.  It runs pg_dump behind the scene.  You will need pgAdmin newer than 1.16 which allowed schema-only option with Plain format only.
The problem is, version 1.20, for example, copies the whole database even if I check Schema-Only.

Back to Plain format.  In pgAdmin we choose a plain format and options as above or use comand line in CMD in folder where pgAdmin was installed as below:

pg_dump.exe --host myhost --port 8035 --username "myuser" --format plain --schema-only --no-owner --no-privileges --verbose --file "filename" "mydbname"

After generating it, in CMD run:

psql -d my-db-name -f "c:\aaa\my-exported-schema-file" -U postgres 

It will ask for the password.  The tool psql comes bundled with pgAdmin, at least it does in version 1.20.

No comments: