We have a multi-tenant database and this is a table in which we have implemented row-level security based on tenant_id:

tenant_id product_id
0 A
0 B
1 1A
1 1B
2 2A
2 2B

Our requirement is that the products associated with tenant_id = 0 should be available to all tenants. Products associated with tenant_id != 0 should only be available to the relevant tenants.

Is there a way to implement this using security definers? Or do we need to have separate tables?

1 Answer 1


you can always write multiple conditions while writing RLS policies. for example: in your case, create policy *policy_name* on *table_name* for all to public using (tenant_id=current_user or tenant_id = 0)

Reference: enter link description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.