Queries
Execute SQL queries using the built-in SQL Editor with syntax highlighting and auto-completion.
SQL Editor
The SQL Editor provides a powerful interface for querying your database:
- Syntax highlighting for SQL keywords
- Auto-completion for table and column names
- Query history
- Export results to CSV
- Keyboard shortcuts for efficiency
Press
Cmd+Enter (Mac) or Ctrl+Enter (Windows) to execute the current query.SELECT Queries
Retrieve data from your tables:
-- Get all users
SELECT * FROM users;
-- Get specific columns
SELECT id, email, full_name FROM users;
-- Filter results
SELECT * FROM users WHERE role = 'admin';
-- Order results
SELECT * FROM users ORDER BY created_at DESC;
-- Limit results
SELECT * FROM users LIMIT 10 OFFSET 20;INSERT Queries
Add new data to your tables:
-- Insert a single row
INSERT INTO users (email, full_name, role)
VALUES ('john@example.com', 'John Doe', 'user');
-- Insert with returning
INSERT INTO users (email, full_name)
VALUES ('jane@example.com', 'Jane Doe')
RETURNING id, email, created_at;
-- Insert multiple rows
INSERT INTO users (email, full_name) VALUES
('user1@example.com', 'User One'),
('user2@example.com', 'User Two'),
('user3@example.com', 'User Three');UPDATE Queries
Modify existing data:
-- Update a single row
UPDATE users
SET full_name = 'John Smith'
WHERE id = 'uuid-here';
-- Update multiple columns
UPDATE users
SET
full_name = 'John Smith',
role = 'admin',
updated_at = NOW()
WHERE email = 'john@example.com';
-- Update with conditions
UPDATE posts
SET published = true
WHERE user_id = 'uuid-here' AND created_at < NOW() - INTERVAL '1 day';Always include a WHERE clause to avoid updating all rows unintentionally.
DELETE Queries
Remove data from tables:
-- Delete a single row
DELETE FROM users WHERE id = 'uuid-here';
-- Delete with conditions
DELETE FROM posts WHERE published = false AND created_at < NOW() - INTERVAL '30 days';
-- Delete all rows (use with caution!)
DELETE FROM temp_data;DELETE operations are permanent. Consider using soft deletes (a deleted_at column) for important data.
JOIN Queries
Combine data from multiple tables:
-- Inner join
SELECT
users.full_name,
posts.title,
posts.created_at
FROM users
INNER JOIN posts ON users.id = posts.user_id;
-- Left join (include users without posts)
SELECT
users.full_name,
COUNT(posts.id) as post_count
FROM users
LEFT JOIN posts ON users.id = posts.user_id
GROUP BY users.id, users.full_name;Aggregate Functions
Perform calculations on your data:
-- Count rows
SELECT COUNT(*) FROM users;
-- Count with condition
SELECT COUNT(*) FROM users WHERE role = 'admin';
-- Sum values
SELECT SUM(amount) FROM orders WHERE status = 'completed';
-- Average
SELECT AVG(price) FROM products;
-- Group by with aggregates
SELECT
role,
COUNT(*) as user_count
FROM users
GROUP BY role;Exporting Results
Export query results to CSV:
- Execute your query in the SQL Editor
- Click the "Export" button above the results
- Choose CSV format
- Download the file
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Cmd/Ctrl + Enter | Execute query |
Cmd/Ctrl + S | Save query |
Cmd/Ctrl + / | Toggle comment |
Cmd/Ctrl + Shift + F | Format SQL |