Skip to main content
Pro plan required. The SQL Editor lets you write raw SQL queries when you need precise control over your database. It’s the power tool for situations where the visual browser isn’t enough.

When to Use the SQL Editor

Most of the time, you can manage your database through the AI chat or the Data Browser. The SQL Editor is for when you need something more specific:

How to Use

1

Open the Database tab

Click the Database tab in your workspace.
2

Navigate to the SQL Editor

Switch to the SQL Editor view within the Database tab.
3

Write your SQL query

Type your query in the editor. You get syntax highlighting and standard editing features to help you write correct SQL.
4

Execute and view results

Run your query and see the results displayed below the editor. SELECT queries return a results table. Other statements show affected row counts or error messages.

Example Queries

Here are some practical queries to get you started.

Count users by signup month

Find posts without comments

Get the most active users

Check for duplicate emails

View RLS policies on a table

Insert sample data

SQL operations execute directly against your live database. Be careful with UPDATE and DELETE queries — there’s no undo.

Tips for Safe SQL

Writing queries against a live database requires some caution. Here are practices that will save you from mistakes:
Use SELECT queries first to verify your WHERE clause before running UPDATE or DELETE.
For example, before running this:
Run this to see what would be deleted:
Once you’ve confirmed the results look right, run the DELETE.

Other Safety Practices

  • Start with SELECT — Always preview what your query will affect
  • Use LIMIT — Add LIMIT 10 to exploratory queries so you don’t pull back thousands of rows
  • Be specific with WHERE — Broad WHERE clauses (or missing ones) can affect more rows than you expect
  • Use transactions — Wrap multi-step operations in BEGIN and COMMIT so you can ROLLBACK if something goes wrong

Using Transactions for Multi-Step Operations

When you need to make several related changes at once, wrap them in a transaction:
If any step fails, you can run ROLLBACK instead of COMMIT and none of the changes will be applied. This keeps your database consistent.
The SQL Editor is a great companion to the AI chat. If the AI generates a query you want to tweak, copy it into the SQL Editor to modify and test it yourself.

SQL Editor vs. AI Chat

Both can execute SQL, but they serve different purposes: Use the AI chat when you know what you want but don’t want to write the SQL. Use the SQL Editor when you need precise control over how the query works.

Database Overview

Learn about all the database management tools available in Nativeline.

Migrations

Track versioned schema changes to your database.