Database Quick Start

Learn how to work with your database in just a few minutes.

1. Where to Write Queries

You have two main places to write database queries:

Supabase Dashboard

For direct database management and testing queries:

  1. Go to your Supabase project dashboard
  2. Click on "SQL Editor" in the sidebar
  3. Write and run your queries

In Your Code

For application features, write queries in your server components or API routes:

// In any server component (pages with no "use client")
import { createClient } from '@/utils/supabase/server'
export default async function Page() {
const supabase = await createClient()
const { data } = await supabase
.from('your_table')
.select('*')
}

2. Basic Operations

Get Data

// Get all profiles
const { data } = await supabase
.from('profiles')
.select('*')
// Get specific profile
const { data } = await supabase
.from('profiles')
.select('*')
.eq('id', userId)

Add Data

// Add a new profile
const { data } = await supabase
.from('profiles')
.insert({
id: userId,
full_name: 'John Doe',
email: 'john@example.com'
})

Update Data

// Update a profile
const { data } = await supabase
.from('profiles')
.update({ full_name: 'Jane Doe' })
.eq('id', userId)

Delete Data

// Delete a profile
const { data } = await supabase
.from('profiles')
.delete()
.eq('id', userId)

3. Available Tables

users

Core user data including profile information, billing details, and terms acceptance

customers

Stripe customer data and subscription status

products

Available subscription products and their metadata

prices

Product pricing information and subscription intervals

Next Steps