DROP_POLICY(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’– 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 ๐Ÿ“

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