DROP_POLICY(7pg15)

πŸ“¦ version 15.19, in opensuse-leap 16.0

🌸 NAME 🌸

DROP POLICY β€” remove a row-level security policy from a table. Yep bestie, this is the DROP POLICY(7) page, and we're making policy-dropping feel like clearing out a group chat you no longer need. πŸ’…


✨ SYNOPSIS ✨

DROP POLICY [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]

That's the whole vibe. Now let's break it down, because the details are giving main character energy. πŸŽ€

πŸ’– DESCRIPTION πŸ’–

DROP POLICY removes the specified policy from the table. Literally its whole job. ✨

Big note though: if the last policy is removed for a table and the table still has row-level security enabled via ALTER TABLE, then the default-deny policy will be used. So yeah, the table doesn't just become a free-for-all β€” default-deny steps in. No cap. πŸ”₯

And if you wanna disable row-level security for a table, ALTER TABLE ... DISABLE ROW LEVEL SECURITY can be used. That works whether policies for the table exist or not. Iconic. πŸ‘‘

πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the policy does not exist. A notice is issued in this case. So it's like "bestie, it's already gone, we're fine" instead of screaming. πŸ™ˆ
  • name β€” the name of the policy to drop.
  • table_name β€” the name (optionally schema-qualified) of the table that the policy is on.
  • CASCADE β€” this key word does not have any effect, since there are no dependencies on policies. It's just out here with no job. πŸ’€
  • RESTRICT β€” same situation: this key word does not have any effect, since there are no dependencies on policies. It's giving decorative. πŸŽ€

🌈 EXAMPLES 🌈

To drop the policy called p1 on the table named my_table:

DROP POLICY p1 ON my_table;

Slay. Clean, simple, done. ✨

πŸ¦‹ COMPATIBILITY πŸ¦‹

DROP POLICY is a PostgreSQL extension. So it's a PostgreSQL thing, not some standard-SQL situation. Iykyk. 🫢

πŸ’œ SEE ALSO πŸ’œ


Bestie reminder: if the last policy gets removed and the table still has row-level security enabled via ALTER TABLE, the default-deny policy will be used. Keep that vibe check in mind. πŸ’–

β€” xoxo, your PostgreSQL 15.19 bestie, dated 2026, signing off from the DROP POLICY(7) page πŸ’…πŸ’–

πŸ“¦ where this page comes from