Skip to main content

Online PostgreSQL Editor

Compose and document PostgreSQL queries with a focused editor—ideal for reviews and teaching.

Need custom conversion?

Completions appear as you type; press Ctrl+Space to open the list. Tab expands snippets where available. Find: Ctrl+F (Cmd+F on Mac). Format: toolbar button or Ctrl+Shift+B for supported languages.

Choose editor font size in pixels

Compose and document PostgreSQL queries with a focused editor—ideal for reviews and teaching.

Filtered SELECT

-- PostgreSQL
SELECT id, email, created_at
FROM users
WHERE active = TRUE
  AND created_at >= CURRENT_DATE - INTERVAL '7 days'
ORDER BY created_at DESC
LIMIT 50;

JOIN + aggregate

SELECT u.id, COUNT(o.id) AS orders
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.id
HAVING COUNT(o.id) > 0;

Window function

SELECT id,
       amount,
       SUM(amount) OVER (PARTITION BY user_id ORDER BY created_at) AS running
FROM payments;

Variables (session)

-- PostgreSQL
SET @limit = 100;
PREPARE stmt FROM 'SELECT * FROM t LIMIT ?';

Conditional filters

SELECT *
FROM products
WHERE (:category IS NULL OR category = :category)
  AND price BETWEEN :min AND :max;

CTE chain

WITH base AS (
  SELECT * FROM events WHERE ts > NOW() - INTERVAL '1 day'
)
SELECT * FROM base WHERE type = 'purchase';

Comments

-- line comment
/* block comment */

Reporting query with CTE

-- PostgreSQL: staged report
WITH daily AS (
  SELECT DATE(created_at) AS d, COUNT(*) AS n
  FROM events
  GROUP BY 1
)
SELECT d, n, SUM(n) OVER (ORDER BY d) AS running
FROM daily
ORDER BY d DESC
LIMIT 30;

Safe migration sketch

-- PostgreSQL: additive change
BEGIN;
  ALTER TABLE users ADD COLUMN IF NOT EXISTS locale TEXT;
  UPDATE users SET locale = 'en' WHERE locale IS NULL;
COMMIT;

Does PostgreSQL code run on ConversionTab servers?
No. Editing happens in your browser. Download the file and run it in your usual compiler, runtime, or platform.
Can I change theme and font size?
Yes. Use the toolbar above the editor; choices persist in local storage for your browser profile.