snipt

Ctrl+h for KB shortcuts

Bash

Export PostgreSQL schema only (no data) and discard ownership

pg_dump --schema-only --no-owner -h {host} -U {user} -f {filename.sql} {database-name}

Description

Export PostgreSQL schema only (no data) and discard ownership
https://snipt.net/embed/e552972d1b42c3d6f5e1a796a7d3355c/
/raw/e552972d1b42c3d6f5e1a796a7d3355c/
e552972d1b42c3d6f5e1a796a7d3355c
bash
Bash
2
2019-06-18T00:51:40
True
False
False
Sep 01, 2016 at 04:22 PM
/api/public/snipt/147682/
export-postgresql-schema-only-no-data-and-discard-ownership
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>pg_dump --schema-only --no-owner -h <span class="o">{</span>host<span class="o">}</span> -U <span class="o">{</span>user<span class="o">}</span> -f <span class="o">{</span>filename.sql<span class="o">}</span> <span class="o">{</span>database-name<span class="o">}</span> </span></pre></div> </td></tr></table>
backup, postgresql
1
2
3
4
--- 
+++ 
@@ -0,0 +1 @@
+pg_dump --schema-only --no-owner -h {host} -U {user} -f {filename.sql} {database-name}