Skip to navigation

Query datasets with SQL in Postman

View as Markdown

Datasets are available on Postman Solo, Team, and Enterprise plans. For more information, see the pricing page.

A view is a SQL query over your dataset’s data sources, which can include both data files (CSV, JSON, NDJSON, or spreadsheets) and live databases. When you add a data file, Postman makes it queryable as a table, so you can filter, combine, and reshape the data with SQL, as you can with databases. A view can also span multiple data sources, so you can join that file to a live database or to other files and return one combined result.

Your tests, scripts, and mocks read from a view, not from the file or database underneath it. You can reshape or replace a source without updating them, as long as the view still returns the fields they expect. You can also define several views over a single source to expose different subsets of rows and columns. This means you don’t need to duplicate or re-upload the data for each scenario.

Views use SQLite-compatible SQL syntax and functions, whether a source is a data file or a MySQL, Postgres, or SQL Server database with a table.

Custom JDBC data sources use the native SQL dialect of the connected database. MySQL, Postgres, or SQL Server sources with no table also use the native dialect, connecting to the whole database instead of a single table. For these sources, SQLite syntax isn’t available, and each view must target a single source.

As you write a query in the view editor, autocomplete suggests SQL keywords, clauses, and your dataset’s source names, based on where your cursor is in the query. To open the suggestions manually, press ⌘+I on Mac or Ctrl+Space on Windows and Linux.

The following examples show common ways to use views with different data sources.

About the example dataset

In the following examples, assume you have a dataset with the following data sources:

  • A local CSV file named customers with the following data:

    customer_id,first_name,last_name,email,country,signup_date,status
    cus_001,Avery,Johnson,avery.johnson001@example.com,United States,2025-01-01,active
    cus_002,Mina,Johnson,mina.johnson002@example.com,India,2025-01-02,active
    cus_003,Leo,Johnson,leo.johnson003@example.com,France,2025-01-03,active
    cus_004,Sofia,Johnson,sofia.johnson004@example.com,Spain,2025-01-04,inactive
    cus_005,Noah,Johnson,noah.johnson005@example.com,Canada,2025-01-05,pending
  • A MySQL database named orders with the following data:

    | order_id | customer_id | amount |
    |----------|-------------|--------|
    | ord_101 | cus_001 | 50.00 |
    | ord_102 | cus_002 | 75.00 |
    | ord_103 | cus_004 | 25.00 |

In a view, reference each data source by its name, used as the table name. In these examples, the customers file’s source is named source_customers and the orders database’s source is named orders.

Select all data

You can create a view that selects all rows and columns.

SELECT * FROM source_customers;

Filter rows

You can filter rows to return only the data your workflow needs.

SELECT customer_id, first_name, last_name, email
FROM source_customers
WHERE status = 'active';

Create new columns

You can create new columns using expressions and aliases in your query. This is useful when your tests or mock servers need values derived from existing data.

SQLite example:

SELECT first_name, last_name, first_name || ' ' || last_name AS full_name
FROM source_customers;

MySQL example:

SELECT order_id, amount, CONCAT(order_id, ' - ', amount) AS order_summary
FROM orders;

Join multiple data sources

You can combine data from multiple data sources, such as a local CSV file and a MySQL table. This is useful when you want a consolidated view of data that’s stored in different places.

Custom JDBC data sources can’t be combined with other source types in a view. Each view on a JDBC source must target only that source.

SELECT source_customers.customer_id, source_customers.first_name, source_customers.last_name, orders.order_id, orders.amount
FROM source_customers
JOIN orders ON source_customers.customer_id = orders.customer_id;