ClickHouse/docs/zh/operations/table_engines/mysql.md
谢磊 d3894b52df [WIP] translate about table-engines (#3660)
* init zh/operations translate

* finish table_engines about Integrations part

* add table_engine index
2018-11-30 22:26:35 +03:00

28 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MySQL
MySQL 引擎可以对存储在远程 MySQL 服务器上的数据执行 `SELECT` 查询。
调用格式:
```
MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']);
```
**调用参数**
- `host:port` — MySQL 服务器地址。
- `database` — 数据库的名称。
- `table` — 表名称。
- `user` — 数据库用户。
- `password` — 用户密码。
- `replace_query` — 将 `INSERT INTO` 查询是否替换为 `REPLACE INTO` 的标志。如果 `replace_query=1`,则替换查询
- `'on_duplicate_clause'` — 将 `ON DUPLICATE KEY UPDATE 'on_duplicate_clause'` 表达式添加到 `INSERT` 查询语句中。例如:`impression = VALUES(impression) + impression`。如果需要指定 `'on_duplicate_clause'`,则需要设置 `replace_query=0`。如果同时设置 `replace_query = 1``'on_duplicate_clause'`,则会抛出异常。
此时,简单的 `WHERE` 子句(例如 ` =, !=, >, >=, <, <=`)是在 MySQL 服务器上执行。
其余条件以及 `LIMIT` 采样约束语句仅在对MySQL的查询完成后才在ClickHouse中执行。
`MySQL` 引擎不支持 [Nullable](../../data_types/nullable.md#data_type-nullable) 数据类型因此当从MySQL表中读取数据时`NULL` 将转换为指定列类型的默认值通常为0或空字符串
[Original article](https://clickhouse.yandex/docs/zh/operations/table_engines/mysql/) <!--hide-->