PostgreSQL Playground

Practise SQL on real PostgreSQL in your browser. Nothing is uploaded.

The examples cover joins, window functions and running totals, JSONB, recursive CTEs, upserts with RETURNING, functions and triggers, and time series: hourly averages, gap filling, moving averages and changes.

About the PostgreSQL Playground

Practise PostgreSQL online without installing a server. The playground runs real PostgreSQL, compiled to WebAssembly (PGlite), inside your browser tab. It starts with a small shop database (customers, products, orders and order_items), and you can import your own CSV, JSON or .sql files.

It is meant for learning SQL, testing queries and exploring small datasets. It is not a hosted database, so applications cannot connect to it, and the data is cleared when you reload the page.

Time series data, such as sensor readings, metrics or prices with timestamps, can be practised here too. The examples make simulated readings with generate_series, group them into hourly buckets with date_trunc, fill the hours with no readings, and compute a one-hour moving average and the change since the last reading, all with ordinary SQL window functions.

Questions

Is this real PostgreSQL?

Yes. It is PostgreSQL 16 compiled to WebAssembly (PGlite), running in your browser. Standard SQL, JSONB, window functions, CTEs and PL/pgSQL work as they do on a server. Network features such as replication, user logins and most extensions are not available.

Can I connect to it from Java, Python or another program?

No. The playground is not a hosted database: there is no server, port or connection string. Java, Python, Node.js, Go, JDBC or ORM code cannot connect to it. Queries run only from the editor on this page.

Is my data uploaded?

No. The database runs inside your browser tab. Your queries and imported files never leave your device.

How much data can I load?

Small to medium files work best, up to a few tens of megabytes. Larger files are limited by your browser's memory.

Is my data saved?

No. Reloading the page resets the database. The text in the editor is kept in your browser so you can continue writing.

Can I practise time series queries here?

Yes. Use the time series examples in the editor: they create simulated sensor readings, then show hourly averages, gaps filled, a moving average and the change between readings. You can also load your own timestamped CSV with the import button.

Is TimescaleDB available?

No. TimescaleDB is an extension for a server install, and it is not in PGlite. The playground uses standard PostgreSQL features such as date_trunc, generate_series and window functions, which work for time series analysis.

More playgrounds

🤖 Use this tool from an AI agent (WebMCP)

This page offers 2 tools that an AI agent running in the browser can call directly, without clicking through the page. A call runs in your tab like the buttons do, and nothing is uploaded.

How to turn it on and try it

  1. Use Chrome 149 or later on a computer. TinyPDF.in is enrolled in Chrome's WebMCP trial, so there is nothing to switch on.
  2. Keep this page open and open the console (F12, then Console).
  3. Paste this:
const tools = await document.modelContext.getTools();
const tool = tools.find(t => t.name === 'run_postgres_sql');
await document.modelContext.executeTool(tool, JSON.stringify({
  "sql": "SELECT city, count(*) AS customers FROM customers GROUP BY city ORDER BY customers DESC LIMIT 3"
}));

In other browsers the page works as usual and offers no agent tools. Examples for every tool and what they return

Using a desktop agent such as Claude Code or Cursor? See how to connect it to this page.