13-tmq.md 1.7 KB
Newer Older
1
---
2
title: Data Subscription
D
danielclow 已提交
3 4
sidebar_label: Data Subscription
description: This document describes the SQL statements related to the data subscription component of TDengine.
5 6
---

7
The information in this document is related to the TDengine data subscription feature.
8

9
## Create a Topic
10 11

```sql
12
CREATE TOPIC [IF NOT EXISTS] topic_name AS subquery;
13 14 15
```


16
You can use filtering, scalar functions, and user-defined scalar functions with a topic. JOIN, GROUP BY, windows, aggregate functions, and user-defined aggregate functions are not supported. The following rules apply to subscribing to a column:
17

18 19 20 21
1. The returned field is determined when the topic is created.
2. Columns to which a consumer is subscribed or that are involved in calculations cannot be deleted or modified.
3. If you add a column, the new column will not appear in the results for the subscription.
4. If you run `SELECT \*`, all columns in the subscription at the time of its creation are displayed. This includes columns in supertables, standard tables, and subtables. Supertables are shown as data columns plus tag columns.
22 23


24
## Delete a Topic
25 26 27 28 29

```sql
DROP TOPIC [IF EXISTS] topic_name;
```

30
If a consumer is subscribed to the topic that you delete, the consumer will receive an error.
31

32
## View Topics
33 34 35 36 37 38 39

## SHOW TOPICS

```sql
SHOW TOPICS;
```

40
The preceding command displays all topics in the current database.
41

42
## Create Consumer Group
43

44
You can create consumer groups only through the TDengine Client driver or the API provided by a connector.
45

46
## Delete Consumer Group
47 48 49 50 51

```sql
DROP CONSUMER GROUP [IF EXISTS] cgroup_name ON topic_name;
```

52
This deletes the cgroup_name in the topic_name.
53

54
## View Consumer Groups
55 56 57 58 59

```sql
SHOW CONSUMERS;
```

60
The preceding command displays all consumer groups in the current database.