In Supabase, if you enable Row Level Security (RLS) on a table but do not create any policies, what will be the effect on data access?
Think about what RLS means for access control when no rules are defined.
Enabling RLS without any policies blocks all access to the table. This is a security feature to prevent unauthorized access until explicit rules are set.
Select the correct SQL command to enable Row Level Security on the 'orders' table.
Look for the exact syntax PostgreSQL uses for enabling RLS.
The correct command to enable RLS is ALTER TABLE table_name ENABLE RLS;. Other options are invalid syntax.
You have a 'messages' table with a column 'user_id' that stores the owner of each message. Which RLS policy correctly restricts access so users can only see their own messages?
Consider the Supabase function that returns the current authenticated user's ID.
The function auth.uid() returns the current user's unique ID in Supabase. Using it in the policy ensures users only access rows where 'user_id' matches their ID.
If you disable Row Level Security on a table that contains sensitive user data, what is the main security risk?
Think about what happens when no row-level restrictions are applied.
Disabling RLS removes row-level restrictions, so any authenticated user can read or write all data in the table, risking data leaks.
Suppose you create two RLS policies on a table with 'USING' clauses. How does Supabase evaluate these policies when a user queries the table?
Consider how PostgreSQL combines multiple row-level security policies.
PostgreSQL combines multiple RLS policies with a logical OR, so if any policy allows access to a row, the user can see it.
