ALTER STATISTICS

|      ALTER STATISTICS      |                       |            |                  |                                   |
|:--------------------------:|-----------------------|------------|------------------|-----------------------------------|
|[Prev](sql-alterserver.html)|[Up](sql-commands.html)|SQL Commands|[Home](index.html)| [Next](sql-altersubscription.html)|

---

[]()

## ALTER STATISTICS

ALTER STATISTICS — change the definition of an extended statistics object

## Synopsis

```
ALTER STATISTICS name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER STATISTICS name RENAME TO new_name
ALTER STATISTICS name SET SCHEMA new_schema
ALTER STATISTICS name SET STATISTICS new_target

```

## Description

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

 You must own the statistics object to use `ALTER STATISTICS`. To change a statistics object's schema, you must also have `CREATE` privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have `CREATE` 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.)

## Parameters

*`name`*

 The name (optionally schema-qualified) of the statistics object to be altered.

*`new_owner`*

 The user name of the new owner of the statistics object.

*`new_name`*

 The new name for the statistics object.

*`new_schema`*

 The new schema for the statistics object.

*`new_target`*

 The statistic-gathering target for this statistics object for subsequent [`ANALYZE`](sql-analyze.html) operations. The target can be set in the range 0 to 10000; alternatively, set it to -1 to revert to using the maximum of the statistics target of the referenced columns, if set, or the system default statistics target ([default\_statistics\_target](runtime-config-query.html#GUC-DEFAULT-STATISTICS-TARGET)). For more information on the use of statistics by the PostgreSQL query planner, refer to [Section 14.2](planner-stats.html).

## Compatibility

 There is no `ALTER STATISTICS` command in the SQL standard.

## See Also

[CREATE STATISTICS](sql-createstatistics.html), [DROP STATISTICS](sql-dropstatistics.html)

---

|[Prev](sql-alterserver.html)|[Up](sql-commands.html)| [Next](sql-altersubscription.html)|
|:---------------------------|:---------------------:|----------------------------------:|
|        ALTER SERVER        |  [Home](index.html)   |         ALTER SUBSCRIPTION        |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>