DROP_STATISTICS(7pg17)
β¨ DROP STATISTICS β¨
ok so bestie, this is the DROP STATISTICS page from the PostgreSQL 17.11 Documentation, and honestly it's a short one β we're literally just yeeting extended statistics objects out of the database π
let's GO.
π NAME π
DROP_STATISTICS β remove extended statistics. that's it. that's the whole vibe. bye-bye stats object π«Ά
πΈ SYNOPSIS πΈ
DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
look at that syntax. so clean. so iconic. no cap β¨
π¦ DESCRIPTION π¦
so DROP STATISTICS removes statistics object(s) from the database. like, gone. deleted. no more extended stats for you, bestie π
but plot twist β not just anyone can do this. only these three qualify:
- the statistics object's owner
- the schema owner
- or a superuser
that's the whole guest list. main character energy only π
π PARAMETERS π
IF EXISTSβ do not throw an error if the statistics object does not exist. instead a notice is issued in this case. lowkey polite of it, honestly πnameβ the name of the statistics object to drop. it's optionally schema-qualified, so you can be allschema.objectabout it if you want πCASCADE,RESTRICTβ okay so these two key words do not have any effect, because there are literally no dependencies on statistics. so yeahβ¦ they're just kind of there. decorative. vibing. π you can type them, nothing will happen, and that's fr fr by design.
π EXAMPLES π
wanna destroy two statistics objects in different schemas, without failing if they don't exist? say less:
DROP STATISTICS IF EXISTS
accounting.users_uid_creation,
public.grants_user_role;
two objects, two schemas, zero drama. ate π
π§ COMPATIBILITY π§
there is no DROP STATISTICS command in the SQL standard. so this is very much a PostgreSQL exclusive, iykyk β
π₯ SEE ALSO π₯
ALTER STATISTICS(ALTER_STATISTICS(7))CREATE STATISTICS(CREATE_STATISTICS(7))
go read those too, bestie, they're the whole friend group π«Ά
π reminder bestie: this is from PostgreSQL 17.11, dated 2026 β so if you're on a different version, vibe check your own docs first, mwah π
slay, and happy dropping β¨πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms