Query datasets with SQL in Postman
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, 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.
Custom JDBC data sources always use the native SQL dialect of the connected database. SQLite syntax isn’t available and each view must target a single JDBC 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
userswith the following data: -
A MySQL database named
orderswith the following data:
In a view, reference each data source by its name, used as the table name. In these examples, the users file’s source is named source_users and the orders database’s source is named orders.
Select all data
You can create a view that selects all rows and columns.
Filter rows
You can filter rows to return only the data your workflow needs.
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:
MySQL example:
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.