gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
6.4KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>REFRESH MATERIALIZED VIEW</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="sql-reassign-owned.html" title="REASSIGN OWNED" /><link rel="next" href="sql-reindex.html" title="REINDEX" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">REFRESH MATERIALIZED VIEW</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-reassign-owned.html" title="REASSIGN OWNED">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-reindex.html" title="REINDEX">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-REFRESHMATERIALIZEDVIEW"><div class="titlepage"></div><a id="id-1.9.3.161.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">REFRESH MATERIALIZED VIEW</span></h2><p>REFRESH MATERIALIZED VIEW — replace the contents of a materialized view</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <em class="replaceable"><code>name</code></em>
  4. [ WITH [ NO ] DATA ]
  5. </pre></div><div class="refsect1" id="id-1.9.3.161.5"><h2>Description</h2><p>
  6. <code class="command">REFRESH MATERIALIZED VIEW</code> completely replaces the
  7. contents of a materialized view. To execute this command you must be the
  8. owner of the materialized view. The old contents are discarded. If
  9. <code class="literal">WITH DATA</code> is specified (or defaults) the backing query
  10. is executed to provide the new data, and the materialized view is left in a
  11. scannable state. If <code class="literal">WITH NO DATA</code> is specified no new
  12. data is generated and the materialized view is left in an unscannable
  13. state.
  14. </p><p>
  15. <code class="literal">CONCURRENTLY</code> and <code class="literal">WITH NO DATA</code> may not
  16. be specified together.
  17. </p></div><div class="refsect1" id="id-1.9.3.161.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">CONCURRENTLY</code></span></dt><dd><p>
  18. Refresh the materialized view without locking out concurrent selects on
  19. the materialized view. Without this option a refresh which affects a
  20. lot of rows will tend to use fewer resources and complete more quickly,
  21. but could block other connections which are trying to read from the
  22. materialized view. This option may be faster in cases where a small
  23. number of rows are affected.
  24. </p><p>
  25. This option is only allowed if there is at least one
  26. <code class="literal">UNIQUE</code> index on the materialized view which uses only
  27. column names and includes all rows; that is, it must not be an
  28. expression index or include a <code class="literal">WHERE</code> clause.
  29. </p><p>
  30. This option may not be used when the materialized view is not already
  31. populated.
  32. </p><p>
  33. Even with this option only one <code class="literal">REFRESH</code> at a time may
  34. run against any one materialized view.
  35. </p></dd><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
  36. The name (optionally schema-qualified) of the materialized view to
  37. refresh.
  38. </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.161.7"><h2>Notes</h2><p>
  39. While the default index for future
  40. <a class="xref" href="sql-cluster.html" title="CLUSTER"><span class="refentrytitle">CLUSTER</span></a>
  41. operations is retained, <code class="command">REFRESH MATERIALIZED VIEW</code> does not
  42. order the generated rows based on this property. If you want the data
  43. to be ordered upon generation, you must use an <code class="literal">ORDER BY</code>
  44. clause in the backing query.
  45. </p></div><div class="refsect1" id="id-1.9.3.161.8"><h2>Examples</h2><p>
  46. This command will replace the contents of the materialized view called
  47. <code class="literal">order_summary</code> using the query from the materialized
  48. view's definition, and leave it in a scannable state:
  49. </p><pre class="programlisting">
  50. REFRESH MATERIALIZED VIEW order_summary;
  51. </pre><p>
  52. </p><p>
  53. This command will free storage associated with the materialized view
  54. <code class="literal">annual_statistics_basis</code> and leave it in an unscannable
  55. state:
  56. </p><pre class="programlisting">
  57. REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA;
  58. </pre></div><div class="refsect1" id="id-1.9.3.161.9"><h2>Compatibility</h2><p>
  59. <code class="command">REFRESH MATERIALIZED VIEW</code> is a
  60. <span class="productname">PostgreSQL</span> extension.
  61. </p></div><div class="refsect1" id="id-1.9.3.161.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-creatematerializedview.html" title="CREATE MATERIALIZED VIEW"><span class="refentrytitle">CREATE MATERIALIZED VIEW</span></a>, <a class="xref" href="sql-altermaterializedview.html" title="ALTER MATERIALIZED VIEW"><span class="refentrytitle">ALTER MATERIALIZED VIEW</span></a>, <a class="xref" href="sql-dropmaterializedview.html" title="DROP MATERIALIZED VIEW"><span class="refentrytitle">DROP MATERIALIZED VIEW</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-reassign-owned.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-reindex.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">REASSIGN OWNED </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> REINDEX</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1