13-tmq.md 1.6 KB
Newer Older
1
---
2 3
sidebar_label: Data Subscription
title: Data Subscription
4 5
---

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

8
## Create a Topic
9 10

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


15
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:
16

17 18 19 20
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.
21 22


23
## Delete a Topic
24 25 26 27 28

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

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

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

## SHOW TOPICS

```sql
SHOW TOPICS;
```

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

41
## Create Consumer Group
42

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

45
## Delete Consumer Group
46 47 48 49 50

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

51
This deletes the cgroup_name in the topic_name.
52

53
## View Consumer Groups
54 55 56 57 58

```sql
SHOW CONSUMERS;
```

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