2018-12-21 19:23:55 +00:00
# Permissions for queries {#permissions_for_queries}
2018-11-20 15:26:56 +00:00
2018-12-04 09:27:38 +00:00
Queries in ClickHouse can be divided into several types:
2018-11-20 15:26:56 +00:00
1. Read data queries: `SELECT` , `SHOW` , `DESCRIBE` , `EXISTS` .
1. Write data queries: `INSERT` , `OPTIMIZE` .
1. Change settings queries: `SET` , `USE` .
1. [DDL ](https://en.wikipedia.org/wiki/Data_definition_language ) queries: `CREATE` , `ALTER` , `RENAME` , `ATTACH` , `DETACH` , `DROP` `TRUNCATE` .
2018-12-04 09:27:38 +00:00
1. `KILL QUERY` .
2018-11-20 15:26:56 +00:00
2018-12-04 09:27:38 +00:00
The following settings regulate user permissions by the type of query:
2018-11-20 15:26:56 +00:00
2018-12-04 09:27:38 +00:00
- [readonly ](#settings_readonly ) — Restricts permissions for all types of queries except DDL queries.
2018-11-20 15:26:56 +00:00
- [allow_ddl ](#settings_allow_ddl ) — Restricts permissions for DDL queries.
2018-12-04 09:27:38 +00:00
`KILL QUERY` can be performed with any settings.
2018-11-20 15:26:56 +00:00
2018-12-21 19:23:55 +00:00
## readonly {#settings_readonly}
2018-11-20 15:26:56 +00:00
Restricts permissions for read data, write data and change settings queries.
2018-12-04 09:27:38 +00:00
See how the queries are divided into types [above ](#permissions_for_queries ).
2018-11-20 15:26:56 +00:00
**Possible values**
2018-12-04 09:27:38 +00:00
- 0 — All queries are allowed.
- 1 — Only read data queries are allowed.
2018-11-20 15:26:56 +00:00
- 2 — Read data and change settings queries are allowed.
2018-12-04 09:27:38 +00:00
After setting `readonly = 1` , the user can't change `readonly` and `allow_ddl` settings in the current session.
2018-11-20 15:26:56 +00:00
2018-12-21 19:23:55 +00:00
When using the `GET` method in the [HTTP interface ](../../interfaces/http.md ), `readonly = 1` is set automatically. To modify data, use the `POST` method.
2018-12-04 09:27:38 +00:00
**Default value**
0
2018-11-20 15:26:56 +00:00
2018-12-21 19:23:55 +00:00
## allow_ddl {#settings_allow_ddl}
2018-11-20 15:26:56 +00:00
Allows/denies [DDL ](https://en.wikipedia.org/wiki/Data_definition_language ) queries.
2018-12-04 09:27:38 +00:00
See how the queries are divided into types [above ](#permissions_for_queries ).
2018-11-20 15:26:56 +00:00
**Possible values**
- 0 — DDL queries are not allowed.
2018-12-04 09:27:38 +00:00
- 1 — DDL queries are allowed.
You cannot execute `SET allow_ddl = 1` if `allow_ddl = 0` for the current session.
**Default value**
2018-11-20 15:26:56 +00:00
2018-12-04 09:27:38 +00:00
1
2018-11-20 15:26:56 +00:00
[Original article ](https://clickhouse.yandex/docs/en/operations/settings/permissions_for_queries/ ) <!--hide-->