DROP_POLICY(7pg14)
π DROP POLICY π
okay bestie, so this is the DROP POLICY(7) page from the PostgreSQL 14.24 Documentation β yes, the big one, the icon itself β and we're gonna get you fluent in deleting row-level security policies like it's nothing. no cap. π
β¨ SYNOPSIS β¨
DROP POLICY [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
like, that's the whole vibe check right there. IF EXISTS is optional, CASCADE/RESTRICT are optional, everything else is load-bearing. π
π¦ DESCRIPTION π¦
DROP POLICY removes the specified policy from the table. boom, gone, she's not coming to the group chat anymore. β¨
β οΈ okay this is the important part, bestie, listen up: if you remove the last policy for a table and that table still has row-level security enabled via ALTER TABLE, then the default-deny policy kicks in. so literally nobody gets through. not you, not your bestie, not the app. nobody. π
and if you do want to turn it off? ALTER TABLE ... DISABLE ROW LEVEL SECURITY can be used to disable row-level security for a table, whether policies for the table exist or not. slay, you always have an out. π«Ά
πΈ PARAMETERS πΈ
IF EXISTSβ do not throw an error if the policy does not exist. instead a notice is issued in this case, so you get a lil "hey, it wasn't there!" instead of a full-on crash. very demure, very mindful. πnameβ the name of the policy to drop. yep. that's the one you're yeeting. π₯table_nameβ the name (optionally schema-qualified) of the table that the policy is on. so likemy_schema.my_tableis valid, iykyk. βCASCADE,RESTRICTβ these key words do not have any effect, since there are no dependencies on policies. they're literally just there. decorative. main character energy with zero lines. π
π EXAMPLES π
to drop the policy called p1 on the table named my_table, you do:
DROP POLICY p1 ON my_table;
that's it. one line. ate and left no crumbs. π
π COMPATIBILITY π
DROP POLICY is a PostgreSQL extension β meaning she's special, she's our girl, other databases don't have her. periodt. π
π§ SEE ALSO π§
CREATE POLICY(CREATE_POLICY(7)) β make the policy in the first place πALTER POLICY(ALTER_POLICY(7)) β tweak it when you change your mind β¨
and that's the whole page, bestie!! π¦ ngl you're now officially a row-level security girlie. this has been PostgreSQL 14.24, dated 2026 πππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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