2021-11-14 15:52:46 +08:00

42 lines
1.1 KiB
Markdown
Raw Permalink 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.

---
title: "ClickHouse 表引擎之 MySQL"
date: 2020-10-08T10:15:00+08:00
lastmod: 2020-10-08T10:15:00+08:00
tags: []
categories: ["clickhouse"]
---
## MySQL 表引擎简介
- 可以与 MySQL 数据库中的表建立映射
- 只支持 SELECT 和 INSERT不支持 UPDATE 和 DELETE
## 创建 MySQL 引擎表
- 声明
```sql
ENGINE = MySQL(
'host:port',
'database',
'table',
'user',
'password'
[,
replace_query,
'on_duplicate_clause'
]
)
```
- host:port: mysql 的地址和端口
- database: mysql 数据库名
- table: mysql 表名
- user: mysql 用户名
- password: mysql 密码
- replace_query: 对应 mysql 的 replace into 语法,默认 0不启用
- on_duplicate_clause: 对应 mysql 的 on duplicate key 语法,默认空,如果要使用,需设置 replace_query 为 0
## MySQL 引擎表一般用法
- 在 mysql 中建表
- 在 clickhouse 中创建对应的 MySQL 引擎表
- 在 clickhouse 中创建 MergeTree 引擎的物化视图,从 MySQL 引擎表中读取数据