mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 12:41:20 +08:00
doc: update docs/postgres.md (#436) 5e12094078
This commit is contained in:
@ -33,7 +33,7 @@
|
||||
<p><a href="https://www.postgresql.org/docs/current/">PostgreSQL</a> 备忘清单为您提供了常用的 PostgreSQL 命令和语句。</p>
|
||||
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#入门-1">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#psql-命令">psql 命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#获得帮助">获得帮助</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#postgresql-工作">PostgreSQL 工作</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#recon-观察">Recon 观察</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#databases-数据库">Databases 数据库</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#tables-表">Tables 表</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#permissions-权限">Permissions 权限</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#columns-列">Columns 列</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#data-数据">Data 数据</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#users-用户">Users 用户</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#schema">Schema</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#postgresql-命令">PostgreSQL 命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#表">表</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#查询缓冲区">查询缓冲区</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#信息">信息</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#连接">连接</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#格式化">格式化</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#输入输出">输入输出</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#变量">变量</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#杂项">杂项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#大对象">大对象</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#各种各样的">各种各样的</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#备份">备份</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#恢复">恢复</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#远程访问">远程访问</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#导入导出-csv">导入/导出 CSV</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#入门-1">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#psql-命令">psql 命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#获得帮助">获得帮助</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#postgresql-工作">PostgreSQL 工作</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#recon-观察">Recon 观察</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#databases-数据库">Databases 数据库</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#tables-表">Tables 表</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#permissions-权限">Permissions 权限</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#columns-列">Columns 列</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#data-数据">Data 数据</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#users-用户">Users 用户</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#schema">Schema</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#postgresql-命令">PostgreSQL 命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#表">表</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#查询缓冲区">查询缓冲区</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#信息">信息</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#连接">连接</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#格式化">格式化</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#输入输出">输入输出</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#变量">变量</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#杂项">杂项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#大对象">大对象</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#各种各样的">各种各样的</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#备份">备份</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#恢复">恢复</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#远程访问">远程访问</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#导入导出-csv">导入/导出 CSV</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#跨版本升级">跨版本升级</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="入门-1"><a aria-hidden="true" tabindex="-1" href="#入门-1"><span class="icon icon-link"></span></a>入门</h3><div class="wrap-body">
|
||||
<p>切换和连接</p>
|
||||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">$ <span class="token function">sudo</span> <span class="token parameter variable">-u</span> postgres psql
|
||||
@ -745,6 +745,27 @@
|
||||
</span><span class="code-line">\copy <span class="token keyword">table</span><span class="token punctuation">(</span>col1<span class="token punctuation">,</span>col1<span class="token punctuation">)</span> <span class="token keyword">FROM</span> <span class="token string">'<path>'</span> CSV
|
||||
</span></code></pre>
|
||||
<p>另见:<a href="https://www.postgresql.org/docs/current/sql-copy.html">复制</a></p>
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="跨版本升级"><a aria-hidden="true" tabindex="-1" href="#跨版本升级"><span class="icon icon-link"></span></a>跨版本升级</h3><div class="wrap-body">
|
||||
<p>pg_upgrade 跨版本升级</p>
|
||||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">$ /usr/lib/postgresql/16/bin/pg_upgrade <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-b</span> /usr/lib/postgresql/15/bin <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-B</span> /usr/lib/postgresql/16/bin <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-d</span> /var/lib/postgresql/15/main <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-D</span> /var/lib/postgresql/16/main <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-o</span> <span class="token string">" -c config_file=/etc/postgresql/15/main/postgresql.conf"</span> <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-O</span> <span class="token string">" -c config_file=/etc/postgresql/16/main/postgresql.conf"</span>
|
||||
</span></code></pre>
|
||||
<ul class="style-none">
|
||||
<li> <code>-b</code> 旧版本二进制文件目录</li>
|
||||
<li> <code>-B</code> 新版本二进制文件目录</li>
|
||||
<li> <code>-d</code> 旧版本数据目录</li>
|
||||
<li> <code>-D</code> 新版本数据目录</li>
|
||||
<li> <code>-o</code> 旧版本主配置文件</li>
|
||||
<li> <code>-O</code> 新版本主配置文件</li>
|
||||
<li> <code>-c</code> 仅<code>check</code>,不执行升级,可先加<code>-c</code>检查是否有报错,没有报错再运行升级</li>
|
||||
</ul>
|
||||
<!--rehype:className=style-none-->
|
||||
<p>使用 <code>pg_upgrade -?</code> 获取完整的选项列表</p>
|
||||
</div></div></div></div></div><div class="wrap h2body-not-exist"><div class="wrap-header h2wrap"><h2 id="另见"><a aria-hidden="true" tabindex="-1" href="#另见"><span class="icon icon-link"></span></a>另见</h2><div class="wrap-body">
|
||||
<ul>
|
||||
<li><a href="https://gist.github.com/apolloclark/ea5466d5929e63043dcf#posgres-cheatsheet">Posgres-cheatsheet</a> <em>(gist.github.com)</em></li>
|
||||
|
Reference in New Issue
Block a user