DROP_POLICY(7pg18)
๐ DROP POLICY ๐
okay bestie, so this is the DROP POLICY page from the PostgreSQL 18.6 docs, and it's lowkey a banger. it's in manual section 7, iykyk. let's get into it ๐ฆ
โจ NAME โจ
DROP_POLICY โ remove a row-level security policy from a table ๐
๐ธ SYNOPSIS ๐ธ
DROP POLICY [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
look at her. so clean. so iconic. no cap. โจ
๐ DESCRIPTION ๐
so like, DROP POLICY removes the specified policy from the table. that's the whole vibe. ๐ซถ
but here's the tea, bestie โ 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. meaning: nobody gets through. it's giving locked-out-of-your-own-house energy. ๐ญ
if you wanna just turn the whole thing off instead, 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. so like, you don't even have to clean up first. periodt. ๐
๐ PARAMETERS ๐
IF EXISTSโ do not throw an error if the policy does not exist. instead, a notice is issued in this case. very "no worries if not" of her. ๐nameโ the name of the policy to drop. gotta know her name to say goodbye. ๐table_nameโ the name (optionally schema-qualified) of the table that the policy is on. yes you can schema-qualify her, she's flexible like that. โจCASCADE/RESTRICTโ okay so these key words do not have any effect, since there are no dependencies on policies. literally zero. they're just here for the vibes. not me pointing that out but like. yeah. ๐
๐ง EXAMPLES ๐ง
wanna drop the policy called p1 on the table named my_table? say less:
DROP POLICY p1 ON my_table;
and she's gone. bye girl ๐
๐ COMPATIBILITY ๐
DROP POLICY is a PostgreSQL extension. so don't go looking for her in the standard, she's not there, she's built different. โญ
๐ SEE ALSO ๐
CREATE POLICY(CREATE_POLICY(7))ALTER POLICY(ALTER_POLICY(7))
the whole policy friend group honestly. go read them, they ate. ๐ฅ
sign-off time ๐ this page is from PostgreSQL 18.6, dated 2026, and it's literally titled DROP POLICY(7). mwah. go drop some policies responsibly bestie, love u ๐โจ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms