Schema Management
Create tables, manage columns, and configure foreign keys in your Supabase PostgreSQL database.
Overview
The Schema Management section provides a visual interface for viewing and modifying the structure of your Supabase PostgreSQL database. Inspect table schemas, add or alter columns, define foreign key relationships, and manage constraints — all without writing DDL statements manually.
Viewing Table Schemas
Navigate to the Schema section from the sidebar or access it from a table’s context menu. Select a table to see its full schema definition.
Column Details
Each column is displayed with:
- Column name — the PostgreSQL column identifier
- Data type — the column type (e.g.,
text,int4,uuid,timestamptz,jsonb,bool) - Nullable — whether the column accepts NULL values
- Default value — the default expression if defined (e.g.,
uuid_generate_v4(),now(),true) - Primary key — indicator if the column is part of the primary key
- Foreign key — referenced table and column if a foreign key constraint exists
Constraints
Below the column list, the schema view displays table-level constraints:
- Primary key — columns that form the primary key
- Unique constraints — columns or column groups with uniqueness requirements
- Check constraints — custom validation expressions
- Foreign key constraints — relationships to other tables with their ON DELETE and ON UPDATE actions
Creating Tables
- Click New Table in the schema toolbar.
- Enter a table name (lowercase, using underscores for multi-word names is conventional).
- Add columns using the column builder (see below).
- Optionally enable RLS on creation (recommended for tables accessible through the API).
- Click Create.
The new table appears in the sidebar and is ready to receive data.
Managing Columns
Adding Columns
- Select a table and click Add Column.
- Enter the column name.
- Select the data type from the type picker:
- Text types:
text,varchar,char - Numeric types:
int2,int4,int8,float4,float8,numeric - Boolean:
bool - Date/Time:
timestamp,timestamptz,date,time,interval - JSON:
json,jsonb - UUID:
uuid - Binary:
bytea - Array types: any of the above as an array (e.g.,
text[],int4[])
- Text types:
- Configure column options:
- Nullable — toggle whether the column accepts NULL values
- Default value — enter a default expression (e.g.,
now(),gen_random_uuid(), a literal value) - Unique — add a unique constraint to the column
- Click Add to apply the change.
The column is added immediately using an ALTER TABLE ... ADD COLUMN statement.
Altering Columns
- Select a column in the schema view and click Edit.
- Modify the column properties:
- Rename — change the column name
- Change type — alter the data type (PostgreSQL will attempt a cast; this may fail if existing data is incompatible)
- Toggle nullable — add or remove the NOT NULL constraint
- Change default — modify or remove the default value expression
- Click Save to apply changes.
Altering a column on a table with existing data may take time for large tables, especially when changing types or adding NOT NULL constraints.
Dropping Columns
- Select a column in the schema view.
- Click Drop Column.
- Confirm the deletion in the dialog.
If other columns or tables depend on the column (e.g., through foreign keys), Stackpane warns you about the dependent objects. You can choose to cascade the drop (removing dependent constraints) or cancel.
Foreign Key Relationships
Viewing Foreign Keys
Foreign keys are displayed both in the column list (as a link icon with the referenced table) and in the constraints section with full details:
- Source column — the column in the current table
- Referenced table — the target table
- Referenced column — the target column
- ON DELETE action — what happens when the referenced row is deleted (CASCADE, SET NULL, RESTRICT, NO ACTION)
- ON UPDATE action — what happens when the referenced key is updated
Creating Foreign Keys
- Select a column and click Add Foreign Key, or use the New Foreign Key button in the constraints section.
- Select the source column in the current table.
- Select the referenced table from the dropdown (lists all tables in the schema).
- Select the referenced column (typically the primary key of the referenced table).
- Choose the ON DELETE action:
- CASCADE — delete the referencing row when the referenced row is deleted
- SET NULL — set the foreign key column to NULL
- RESTRICT — prevent deletion of the referenced row
- NO ACTION — similar to RESTRICT, checked at end of transaction
- Choose the ON UPDATE action (same options as ON DELETE).
- Click Create.
Removing Foreign Keys
- Select the foreign key constraint in the constraints section.
- Click Drop Constraint.
- Confirm in the dialog.
Index Management
Viewing Indexes
The schema view lists all indexes on the selected table:
- Index name — the PostgreSQL index identifier
- Columns — the indexed columns
- Type — index type (B-tree, Hash, GIN, GiST, etc.)
- Unique — whether the index enforces uniqueness
Creating Indexes
- Click New Index in the schema toolbar.
- Select one or more columns to include in the index.
- Choose the index type (B-tree is the default and most common).
- Optionally mark the index as unique.
- Click Create.
Index creation runs in the background. For large tables, this may take some time.
Tips
- Use
uuidwithgen_random_uuid()as the default for primary key columns — this is the Supabase convention - Enable RLS when creating tables that will be accessed through the Supabase client API
- Use
timestamptzinstead oftimestampto store timezone-aware dates - Add foreign keys to enforce referential integrity and enable Stackpane’s foreign key navigation in the Table Browser
- Be cautious when altering columns on production tables with large datasets — type changes may lock the table during the migration
- Use the CASCADE option on foreign key ON DELETE only when you intend for dependent rows to be automatically removed