DROP_POLICY(7pg16)

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

πŸ’– DROP POLICY(7) πŸ’–

Okay bestie, welcome to the DROP POLICY(7) page from the PostgreSQL 16.15 Documentation β€” this is the one where we learn how to yeet a row-level security policy off a table. Slay.


✨ NAME ✨

DROP_POLICY β€” remove a row-level security policy from a table. No cap, that's literally the whole vibe.


πŸ¦‹ SYNOPSIS πŸ¦‹

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

πŸ’… DESCRIPTION πŸ’…

So DROP POLICY removes the specified policy from the table. Simple, iconic, done.

But listen: 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. That's the plot twist, bestie.

And if you wanna turn row-level security off for a table entirely, 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. Periodt.


πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the policy does not exist. A notice is issued in this case. So it's giving polite, not dramatic.
  • name β€” the name of the policy to drop. Bye, policy.
  • table_name β€” the name (optionally schema-qualified) of the table that the policy is on.
  • CASCADE, RESTRICT β€” these key words do not have any effect, since there are no dependencies on policies. They're just there looking cute, honestly.

🌈 EXAMPLES 🌈

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

DROP POLICY p1 ON my_table;

Ate. No crumbs.


πŸ”₯ COMPATIBILITY πŸ”₯

DROP POLICY is a PostgreSQL extension. It's a PostgreSQL original, iykyk.


🌸 SEE ALSO 🌸


πŸ’– Friendly reminder: if you drop the last policy and row-level security is still enabled via ALTER TABLE, the default-deny policy will be used. That's not me being extra β€” that's just the docs.

Cute little sign-off tea: this whole page is from PostgreSQL 16.15, dated 2026, and it's literally the DROP POLICY(7) manual page. Bye bestie, go drop your policies responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from