This commit is contained in:
2021-11-14 14:32:08 +08:00
parent f75ad8bedd
commit b0f6120151
152 changed files with 22219 additions and 8 deletions

41
content/post/ch-mysql.md Normal file
View File

@@ -0,0 +1,41 @@
---
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 引擎表中读取数据