2021-05-28 13:48:19 -04:00
---
layout: default
2021-05-24 19:50:29 -04:00
title: Query Workbench
2021-05-28 13:48:19 -04:00
parent: SQL
nav_order: 1
2021-05-28 18:20:24 -04:00
redirect_from: /docs/sql/workbench/
2021-05-28 13:48:19 -04:00
---
2021-05-24 19:50:29 -04:00
# Query Workbench
2021-05-05 13:09:47 -04:00
2021-05-25 15:05:54 -04:00
Use the Query Workbench to easily run on-demand SQL queries, translate SQL into its REST equivalent, and view and save results as text, JSON, JDBC, or CSV.
2021-05-28 13:48:19 -04:00
## Quick start
To get started with SQL Workbench, choose **Dev Tools** in OpenSearch Dashboards and use the `bulk` operation to index some sample data:
```json
PUT accounts/_bulk?refresh
{"index":{"_id":"1"}}
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
{"index":{"_id":"6"}}
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
{"index":{"_id":"13"}}
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}
{"index":{"_id":"18"}}
{"account_number":18,"balance":4180,"firstname":"Dale","lastname":"Adams","age":33,"gender":"M","address":"467 Hutchinson Court","email":"daleadams@boink.com","city":"Orick","state":"MD"}
```
Then return to SQL Workbench.
### List indices
To list all your indices:
```sql
SHOW TABLES LIKE %
```
2021-05-24 19:50:29 -04:00
| TABLE_NAME
| :---
| accounts
2021-05-28 13:48:19 -04:00
### Read data
After you index a document, retrieve it using the following SQL expression:
```sql
SELECT *
FROM accounts
WHERE _id = 1
```
2021-05-24 19:50:29 -04:00
| account_number | firstname | gender | city | balance | employer | state | email | address | lastname | age
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :---
| 1 | Amber | M | Brogan | 39225 | Pyrami | IL | amberduke@pyrami.com | 880 Holmes Lane | Duke | 32
2021-05-28 13:48:19 -04:00
### Delete data
To delete a document from an index, use the `DELETE` clause:
```sql
DELETE
FROM accounts
WHERE _id = 0
```
2021-05-24 19:50:29 -04:00
| deleted_rows
| :---
| 1