Home Explore Blog Models CI



postgresql

1st chunk of `doc/src/sgml/ref/alter_statistics.sgml`
c83fbae834513067762e1e8dfc82e278d490eb3445cca1b300000001000008a2
<!--
doc/src/sgml/ref/alter_statistics.sgml
PostgreSQL documentation
-->

<refentry id="sql-alterstatistics">
 <indexterm zone="sql-alterstatistics">
  <primary>ALTER STATISTICS</primary>
 </indexterm>

 <refmeta>
  <refentrytitle>ALTER STATISTICS</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>ALTER STATISTICS</refname>
  <refpurpose>
   change the definition of an extended statistics object
  </refpurpose>
 </refnamediv>

 <refsynopsisdiv>
<synopsis>
ALTER STATISTICS <replaceable class="parameter">name</replaceable> OWNER TO { <replaceable class="parameter">new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER STATISTICS <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
ALTER STATISTICS <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
ALTER STATISTICS <replaceable class="parameter">name</replaceable> SET STATISTICS { <replaceable class="parameter">new_target</replaceable> | DEFAULT }
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>ALTER STATISTICS</command> changes the parameters of an existing
   extended statistics object.  Any parameters not specifically set in the
   <command>ALTER STATISTICS</command> command retain their prior settings.
  </para>

  <para>
   You must own the statistics object to use <command>ALTER STATISTICS</command>.
   To change a statistics object's schema, you must also
   have <literal>CREATE</literal> privilege on the new schema.
   To alter the owner, you must be able to <literal>SET ROLE</literal> to the
   new owning role, and that role must have <literal>CREATE</literal>
   privilege on the statistics object's schema.
   (These restrictions enforce that altering
   the owner doesn't do anything you couldn't do by dropping and recreating
   the statistics object.  However, a superuser can alter ownership of any
   statistics object anyway.)
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

   <para>
    <variablelist>
     <varlistentry>

Title: ALTER STATISTICS
Summary
The SQL command `ALTER STATISTICS` modifies the properties of an existing extended statistics object in PostgreSQL. This includes changing the owner, renaming the object, moving it to a different schema, and setting the statistics target. To use ALTER STATISTICS, you must own the statistics object. Changing the schema requires CREATE privilege on the new schema, and altering the owner requires the ability to SET ROLE to the new owner and CREATE privilege on the object's schema. Superusers can alter the ownership of any statistics object.