Updated on 2024-08-20 GMT+08:00

DROP ROW LEVEL SECURITY POLICY

Function

Deletes a row-level security policy from a table.

Precautions

Only the table owner or administrators can delete a row-level security policy from the table.

Syntax

1
DROP [ ROW LEVEL SECURITY ] POLICY [ IF EXISTS ] policy_name ON table_name [ CASCADE | RESTRICT ];

Parameter Description

  • IF EXISTS

    Reports a notice instead of an error if the specified row-level security policy does not exist.

  • policy_name

    Specifies the name of the row-level security policy to be deleted.

  • table_name

    Specifies the name of the table containing the row-level security policy.

  • CASCADE | RESTRICT

    Currently, no objects depend on row-level security policies. Therefore, CASCADE is equivalent to RESTRICT, and they are reserved to ensure backward compatibility.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
-- Create the data table all_data.
gaussdb=# CREATE TABLE all_data(id int, role varchar(100), data varchar(100));

-- Create a row-level security policy.
gaussdb=# CREATE ROW LEVEL SECURITY POLICY all_data_rls ON all_data USING(role = CURRENT_USER);

-- Delete the row-level security policy.
gaussdb=# DROP ROW LEVEL SECURITY POLICY all_data_rls ON all_data;

-- Delete the all_data table.
gaussdb=# DROP TABLE all_data;