Home postgreSQL backup tables and views
Reply: 1

postgreSQL backup tables and views

Hamed Salimian
1#
Hamed Salimian Published in 2018-02-14 06:16:34Z

I want to have backup of my database, but using pgadmin III I can only restore tables, but I want my views be restored as well. Is there any way doing that?

tnx

Vao Tsun
2#
Vao Tsun Reply to 2018-02-14 10:12:30Z

you could do this task with CLI, eg:

-bash-4.2$ pg_dump -s $(psql -c "select string_agg('-t '||relname,' ') from pg_class where relkind='v' and relnamespace='public'::regnamespace" -At) | grep -i create
CREATE VIEW avva AS
CREATE VIEW v AS

Of course without grep to get the full definition.

otherwise you have to repeat for every view

or create in schema backup, DumpOptions #1 choose Only Schema...

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313135 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO