Getting started
SQL Console
Query your Project's PostgreSQL database directly from the console for exploring, reporting, and careful maintenance.
Open it
- Open your Project in the console.
- Select SQL.
- Write a query and run it. Results appear below as a table.
Example
select status, count(*) as total
from posts
group by status
order by total desc
limit 20;From code
Superuser tools in the SDKs can run SQL too. Use them only in trusted server code, never in apps your users run.
// server-side only, signed in as a superuser
const result = await rb.admin.sql("select count(*) from posts");Use SQL safely
- Start with select when exploring unfamiliar data.
- Limit large results and filter by indexed columns.
- Wrap related changes in a transaction.
- Back up production data before destructive statements.
Found something wrong on this page?
Fix it yourself. The link below opens this file in GitHub's editor and forks the repository for you if you need one, and your change becomes a pull request without leaving the browser.