---
title: "ClickHouse 视图之 Live View"
date: 2020-10-08T19:05:00+08:00
lastmod: 2020-10-08T19:05:00+08:00
tags: []
categories: ["clickhouse"]
---

## Live View 视图简介
- 类似时间监听器
- 需设置 allow_experimental_live_view 为 1，检查
    ```sql
    SELECT name, value FROM system.settings WHERE name LIKE '%live_view%';
    ```

## 创建 Live View 视图
- 创建
    ```sql
    CREATE LIVE VIEW lv_name AS SELECT count(*) FROM table_name;
    ```

- 监听
    ```sql
    WATCH lv_name
    ```

