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:| Use Case | Example |
|---|---|
| Complex queries | Joins, subqueries, aggregations the AI can’t generate through chat |
| Bulk operations | INSERT, UPDATE, or DELETE across many rows at once |
| Custom analytics | Ad-hoc reports and data exploration |
| Debugging | Investigate data issues with targeted queries |
| Testing queries | Try out SQL before incorporating it into your app logic |
How to Use
Write your SQL query
Type your query in the editor. You get syntax highlighting and standard
editing features to help you write correct SQL.
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
Tips for Safe SQL
Writing queries against a live database requires some caution. Here are practices that will save you from mistakes: For example, before running this:Other Safety Practices
- Start with SELECT — Always preview what your query will affect
- Use LIMIT — Add
LIMIT 10to 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
BEGINandCOMMITso you canROLLBACKif something goes wrong
Using Transactions for Multi-Step Operations
When you need to make several related changes at once, wrap them in a transaction: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:| SQL Editor | AI Chat |
|---|---|
| You write the SQL yourself | AI generates SQL from your description |
| Full control over every detail | Faster for common operations |
| Best for debugging and exploration | Best for creating tables, migrations, CRUD |
| Results displayed in a table | Results described in conversation |
Related
Database Overview
Learn about all the database management tools available in Nativeline.
Migrations
Track versioned schema changes to your database.