↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQL Commands

DROP STATISTICS

remove extended statistics

English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

anchor
SQL-DROPSTATISTICS
file
sql-dropstatistics.html
lang
en
name
DROP STATISTICS
purpose
remove extended statistics
purpose zh
删除扩展统计对象
sections same as
Unknown
slug
18
synopsis html
DROP STATISTICS [ IF EXISTS ] <em class="replaceable"><code>name</code></em> [, ...] [ CASCADE | RESTRICT ]
synopsis text
DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

Syntax

DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
Syntax diagrams

Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.

DROP STATISTICS IF EXISTS name , CASCADE RESTRICT

Definition PG 18

DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

Description

DROP STATISTICS removes statistics object(s) from the database. Only the statistics object's owner, the schema owner, or a superuser can drop a statistics object.

Parameters

IF EXISTS

Do not throw an error if the statistics object does not exist. A notice is issued in this case.

name

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

CASCADE
RESTRICT

These key words do not have any effect, since there are no dependencies on statistics.

Examples

To destroy two statistics objects in different schemas, without failing if they don't exist:

DROP STATISTICS IF EXISTS
    accounting.users_uid_creation,
    public.grants_user_role;

Compatibility

There is no DROP STATISTICS command in the SQL standard.

See Also

ALTER STATISTICS, CREATE STATISTICS

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:b066b0f1578189f0136373295b973de326461f2dd974a745c6894ac718c22801

Text language: en · wiki-repair-20261023:b066b0f1578189f0136373295b973de326461f2dd974a745c6894ac718c22801