Loading Depth Study
Preparing your workspace
Row Level Security allows PostgreSQL policies to decide which rows are accessible for a given database request.
RLS is one of the most important Supabase concepts. When enabled on a table, access is controlled by PostgreSQL policies. Policies can use the current authenticated user's identity through auth.uid() and can compare that identity against row data. RLS can control SELECT, INSERT, UPDATE, and DELETE independently. The goal is to make authorization a database-enforced rule rather than trusting the client to behave correctly.
A student should be able to read and update only their own profile, while an admin may have permission to manage many users.
alter table profiles enable row level security; create policy "Users can read their own profile" on profiles for select using (auth.uid() = id);
RLS is enabled and a policy allows authenticated users to read only the profile row matching their own user ID.