# Browse the data

List schemas and tables, read rows and run one read-only query at a time, without a client of your own.

The data browser connects from the platform's control plane with the database's master
credential, so you need no client of your own. Replace _ewdb-0123456789ab_ with your database's
id.

## Prerequisites

- Permission for `rds:QueryDatabase` on the database. It is a sensitive read: the read-only presets
  do not include it, and every use, allowed or refused, is recorded in the audit log.
- The database is available.
- The control plane can reach the database. A private cluster is reached on its primary's own
  address. A private database the control plane cannot reach answers with an error that starts
  `This database is private, so it accepts connections only from inside its own network`; connect
  from an instance in its network instead.
- In the console, also `rds:DescribeDBInstances` to open the database's page (without it the page is
  not found).

## Browse and query

**Console**
1. Open the database, then choose **Data**.
2. In **Tables**, choose a table's name to see its rows, 50 to a page; choose **Next** and
   **Previous** to page, and **All tables** to go back.
3. To run a statement, choose **Query**, enter it, and choose **Run** (or press Ctrl+Enter).

**CLI**
```sh
dcloud rds data list-relations ewdb-0123456789ab
dcloud rds data read-rows ewdb-0123456789ab --schema public --table orders --limit 50
dcloud rds data run-query ewdb-0123456789ab --sql "SELECT count(*) FROM orders"
```

**API**
```http
POST /rds/api/instances/ewdb-0123456789ab/data/query
{ "sql": "SELECT count(*) FROM orders", "limit": 200 }
```

**Terraform:** not available. Reading data is not configuration.

## Result

The tables list shows the tables, views and materialized views outside the system schemas, with
sizes and row estimates (the planner's estimate, not an exact count). `read-rows` returns 50 rows by
default and at most 200 to a page.

A query is one statement that starts with `SELECT`, `WITH`, `TABLE`, `VALUES`, `EXPLAIN` (without
`ANALYZE`) or `SHOW`. It runs in a `READ ONLY` transaction with a 15-second statement timeout and
returns 200 rows by default, at most 500 through the CLI and API; the console asks for 200 and says
when there are more. A statement that is refused or fails returns 400 with the reason, for example
`Run one statement at a time — everything after the first semicolon was refused.`

A database that is not available is refused with
`This database is <status>. Data is readable once it is available.` (409).

## Related

- [Find slow queries](find-slow-queries.md)
- `rds.data.run-query` · `dcloud rds data run-query`
