SQL Query Editor
Write and execute SQL queries against your Supabase PostgreSQL database with result display.
Overview
The SQL Query Editor lets you write and execute raw SQL against your Supabase PostgreSQL database directly from Stackpane. Run SELECT queries to explore data, execute DDL statements to modify your schema, or call PostgreSQL functions — all with results displayed in a table format.
Opening the Editor
Navigate to the SQL Editor from the sidebar or open it from the toolbar while browsing a table. When opened from a table context, the editor pre-fills with a basic SELECT * FROM table_name LIMIT 100 query.
Writing Queries
The editor provides a multi-line text area with the following features:
- Syntax highlighting — SQL keywords, table names, strings, and numbers are color-coded
- Auto-completion — table and column names are suggested as you type
- Multi-statement support — separate multiple statements with semicolons
Supported Operations
The editor supports all SQL operations that the PostgREST RPC interface allows:
- SELECT — query data with full PostgreSQL syntax (joins, subqueries, CTEs, window functions)
- INSERT / UPDATE / DELETE — modify data directly
- CREATE / ALTER / DROP — schema modification statements
- PostgreSQL functions — call functions via
SELECT function_name(args)
Executing Queries
Click Run or press Cmd+Enter to execute the current query. A loading indicator appears while the query is in progress.
Result Display
Query results are displayed in a table below the editor with the following features:
- Column headers match the returned column names or aliases
- Results are paginated for large result sets
- Click column headers to sort results locally
- NULL values are displayed with a distinct label
Row Count
The result bar shows the number of rows returned by the query. For modification statements (INSERT, UPDATE, DELETE), the affected row count is displayed instead.
Error Handling
If a query fails, the error message from PostgreSQL is displayed below the editor with:
- Error code — the PostgreSQL error code (e.g.,
42P01for undefined table) - Message — a human-readable description of the error
- Detail — additional context when available (e.g., which column caused a constraint violation)
- Hint — PostgreSQL’s suggested fix when available
Query History
Stackpane automatically records every executed query in a local history:
- Click the History button in the toolbar to open the history panel.
- Browse previously executed queries sorted by most recent.
- Click any history entry to load it into the editor.
- History entries show the query text, execution timestamp, and whether it succeeded or failed.
Query history is stored per-connection and persists across sessions.
Saved Queries
Save frequently used queries for quick access:
- Write your query in the editor.
- Click Save and enter a descriptive name (e.g., “Active users last 30 days”).
- Access saved queries from the Saved Queries menu in the toolbar.
Saved queries are stored per-connection. Click a saved query to load it into the editor, or delete it from the menu to remove it.
PostgREST RPC
Stackpane executes SQL through the Supabase PostgREST API using the RPC endpoint. This means:
- Queries run with the permissions of the API key used in your connection (anon or service role)
- When using the anon key, RLS policies are enforced on the query results
- When using the service role key, RLS is bypassed and all data is accessible
- Transaction support depends on the PostgREST configuration
Tips
- Use
LIMITclauses on SELECT queries to avoid loading large result sets unnecessarily - Use the service role key connection for DDL statements that require elevated permissions
- Check query history to revisit and refine queries from previous sessions
- Save complex or frequently used queries to avoid rewriting them
- Use CTEs (
WITHclauses) to break complex queries into readable steps - Press Cmd+Enter for quick execution without reaching for the Run button