DROP_POLICY(7pg16)
π 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 πΈ
CREATE POLICY (CREATE_POLICY(7))ALTER POLICY (ALTER_POLICY(7))
π 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
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-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