mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-18 05:01:21 +08:00
doc: update docs/postgres.md (#436) 5e12094078
This commit is contained in:
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 5.5 MiB After Width: | Height: | Size: 5.5 MiB |
@ -33,7 +33,7 @@
|
|||||||
<p><a href="https://www.postgresql.org/docs/current/">PostgreSQL</a> 备忘清单为您提供了常用的 PostgreSQL 命令和语句。</p>
|
<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">
|
</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>
|
<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">
|
</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>
|
<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
|
<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><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>
|
</span></code></pre>
|
||||||
<p>另见:<a href="https://www.postgresql.org/docs/current/sql-copy.html">复制</a></p>
|
<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">
|
</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>
|
<ul>
|
||||||
<li><a href="https://gist.github.com/apolloclark/ea5466d5929e63043dcf#posgres-cheatsheet">Posgres-cheatsheet</a> <em>(gist.github.com)</em></li>
|
<li><a href="https://gist.github.com/apolloclark/ea5466d5929e63043dcf#posgres-cheatsheet">Posgres-cheatsheet</a> <em>(gist.github.com)</em></li>
|
||||||
|
@ -896,8 +896,8 @@
|
|||||||
<a href="https://github.com/13812700839" title="花殇">
|
<a href="https://github.com/13812700839" title="花殇">
|
||||||
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇">
|
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/dousha0w0" title="Haoran Xu">
|
<a href="https://github.com/dousha0w0" title="dousha0w0">
|
||||||
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Haoran Xu">
|
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="dousha0w0">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/Brid9e" title="Joe">
|
<a href="https://github.com/Brid9e" title="Joe">
|
||||||
<img src="https://avatars.githubusercontent.com/u/85558909?v=4" width="42;" alt="Joe">
|
<img src="https://avatars.githubusercontent.com/u/85558909?v=4" width="42;" alt="Joe">
|
||||||
@ -1357,7 +1357,7 @@
|
|||||||
<!--rehype:class=home-card home-links-->
|
<!--rehype:class=home-card home-links-->
|
||||||
<p>如果你有资源,可以很方便<a href="https://github.com/jaywcjlove/reference/issues/102#issue-1451649637">部署 web 版</a>,这非常简单,只需要克隆 <a href="https://github.com/jaywcjlove/reference/tree/gh-pages">gh-pages</a> 分支代码到你的静态服务就可以了,还可以使用 <a href="https://hub.docker.com/r/wcjiang/reference">docker</a> 快捷部署 web 版。</p>
|
<p>如果你有资源,可以很方便<a href="https://github.com/jaywcjlove/reference/issues/102#issue-1451649637">部署 web 版</a>,这非常简单,只需要克隆 <a href="https://github.com/jaywcjlove/reference/tree/gh-pages">gh-pages</a> 分支代码到你的静态服务就可以了,还可以使用 <a href="https://hub.docker.com/r/wcjiang/reference">docker</a> 快捷部署 web 版。</p>
|
||||||
|
|
||||||
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang. Updated on 2023/09/19 17:30:18</footer></footer><script src="data.js?v=1.5.1" defer></script><script src="js/fuse.min.js?v=1.5.1" defer></script><script src="js/main.js?v=1.5.1" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
|
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang. Updated on 2023/09/19 22:40:13</footer></footer><script src="data.js?v=1.5.1" defer></script><script src="js/fuse.min.js?v=1.5.1" defer></script><script src="js/main.js?v=1.5.1" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
|
||||||
<path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
|
<path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
|
||||||
</svg><input id="mysearch-input" type="search" placeholder="搜索" autocomplete="off"><div class="mysearch-clear"></div></div><button id="mysearch-close" type="button">搜索</button></div><div class="mysearch-result"><div id="mysearch-menu"></div><div id="mysearch-content"></div></div></div></div></body>
|
</svg><input id="mysearch-input" type="search" placeholder="搜索" autocomplete="off"><div class="mysearch-clear"></div></div><button id="mysearch-close" type="button">搜索</button></div><div class="mysearch-result"><div id="mysearch-menu"></div><div id="mysearch-content"></div></div></div></div></body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user