# Overview (/docs/reference/sql)



SQL [#sql]

RawTree is a ClickHouse fork. SQL defines queries, writes, physical layouts,
access controls, and workload scheduling. Users, roles, grants, row policies,
settings profiles, workloads, and resources are database constructs.

RawTree Cloud and RawTree BYOC expose supported operations through the Query
API. The service can also manage database objects on your behalf, such as
users for database-role API keys.

Query endpoint [#query-endpoint]

The query API accepts a JSON body with a `sql` field:

```json
{"sql":"SELECT * FROM events LIMIT 10"}
```

`/v1/query` accepts one statement per request. It supports reads and selected
write and management statements, including role, policy, profile, and workload
operations. Each statement has its own permission and syntax limits.
See [SQL statements](/docs/reference/sql/statements) for accepted forms.

An operation rejected by this API can still exist in RawTree. The API validates
its supported forms before the database executes them. See
[ClickHouse compatibility and API scope](/docs/reference/clickhouse-compatibility).

Common patterns [#common-patterns]

```sql
SELECT * FROM events LIMIT 10;
```

```sql
SELECT action, count() AS total
FROM events
GROUP BY action
ORDER BY total DESC
LIMIT 10;
```

```sql
SELECT user.id, count() AS total
FROM events
GROUP BY user.id
ORDER BY total DESC
LIMIT 10;
```

```sql
SELECT __raw_data FROM events LIMIT 10;
```

```sql
SELECT __raw_data.user.id, __raw_data.event FROM events LIMIT 10;
```

Agent defaults [#agent-defaults]

* Start with `SELECT`.
* Add `LIMIT` while exploring.
* Use dot notation for nested fields.
* Use `__raw_data` to read the original JSON object RawTree stored for each row.
* Use logs when a query fails.

Generated reference [#generated-reference]

The SQL reference includes statement pages plus generated settings, data types,
formats, system tables, functions, and aggregate functions.

Generated pages describe the RawTree binary used to build this reference.
They are not a list of operations exposed by the Query API. Descriptions can
retain upstream ClickHouse names and deployment notes. A reference to ClickHouse
Cloud does not establish availability in RawTree Cloud or RawTree BYOC.

Use these pages for engine syntax and behavior. Use the statement pages and
API reference for service access, restrictions, and permissions.
