TDengine 3.3.6.3 虚拟表简单验证

涛思新出的版本提供虚拟表功能,完美解决了多值窄表查询时需要写程序把窄表变成宽表的处理过程,更加优雅。

超级表定义如下:

bash 复制代码
CREATE STABLE st01 (ts TIMESTAMP,v0 INT,v1 BIGINT,v2 FLOAT,v3 BOOL) TAGS (device VARCHAR(32),vtype VARCHAR(32));

提供多个值域,通过tags的vtype字段定义哪个字段有效,使用统一的模型支持数据写入,然后定义查询虚拟表方便查询

bash 复制代码
create vtable v1 ( ts timestamp, c1 int from d1001.v0, c2 float from d1002.v2);

测试下来还是很容易的,具体过程见下面代码和执行结果。

bash 复制代码
ubuntu@ubuntu:~$ taos 
Welcome to the TDengine Command Line Interface, Native Client Version:3.3.6.3 
Copyright (c) 2025 by TDengine, all rights reserved.


  *********************************  Tab Completion  *************************************
  *   The TDengine CLI supports tab completion for a variety of items,                   *
  *   including database names, table names, function names and keywords.                *
  *   The full list of shortcut keys is as follows:                                      *
  *    [ TAB ]        ......  complete the current word                                  *
  *                   ......  if used on a blank line, display all supported commands    *
  *    [ Ctrl + A ]   ......  move cursor to the st[A]rt of the line                     *
  *    [ Ctrl + E ]   ......  move cursor to the [E]nd of the line                       *
  *    [ Ctrl + W ]   ......  move cursor to the middle of the line                      *
  *    [ Ctrl + L ]   ......  clear the entire screen                                    *
  *    [ Ctrl + K ]   ......  clear the screen after the cursor                          *
  *    [ Ctrl + U ]   ......  clear the screen before the cursor                         *
  ****************************************************************************************

Server is TDengine Community Edition, ver:3.3.6.3 and will never expire.

taos> create database pascal;
Create OK, 0 row(s) affected (0.111764s)

taos> use pascal;
Database changed.

taos> CREATE STABLE st01 (ts TIMESTAMP,v0 INT,v1 BIGINT,v2 FLOAT,v3 BOOL) TAGS (device VARCHAR(32),vtype VARCHAR(32));
Create OK, 0 row(s) affected (0.002556s)

taos> INSERT INTO d1001 using st01 tags('dev01','int') (ts,v0) values(now(),1) d1002 using st01 tags('dev02','float') (ts,v2) values(now(),1.3);
Insert OK, 2 row(s) affected (0.001621s)

taos> INSERT INTO d1001 using st01 tags('dev01','int') (ts,v0) values(now(),2) d1002 using st01 tags('dev02','float') (ts,v2) values(now(),2.2);
Insert OK, 2 row(s) affected (0.000726s)

taos> INSERT INTO d1001 using st01 tags('dev01','int') (ts,v0) values(now(),3) d1002 using st01 tags('dev02','float') (ts,v2) values(now(),3.3);
Insert OK, 2 row(s) affected (0.000654s)

taos> create vtable v1 ( ts timestamp, c1 int from d1001.v0, c2 float from d1002.v2);
Create OK, 0 row(s) affected (0.000869s)

taos> select * from v1;
           ts            |     c1      |          c2          |
===============================================================
 2025-04-16 15:14:59.910 |           1 |                  1.3 |
 2025-04-16 15:15:10.668 |           2 |                  2.2 |
 2025-04-16 15:15:21.268 |           3 |                  3.3 |
Query OK, 3 row(s) in set (0.002706s)

多值窄表模型存储测试,参考之前验证结果:TDengine不同数据模型下的存储对比验证_tdengine检查表是否存在-CSDN博客

相关推荐
TDengine (老段)2 天前
TDengine IDMP 可视化 —— 饼图
大数据·数据库·人工智能·物联网·时序数据库·tdengine·涛思数据
TDengine (老段)2 天前
TDengine IDMP 可视化 —— 面板
大数据·数据库·人工智能·物联网·ai·时序数据库·tdengine
TDengine (老段)4 天前
TDengine IDMP 可视化 ——柱状图
大数据·数据库·物联网·时序数据库·iot·tdengine·涛思数据
涛思数据(TDengine)5 天前
TDengine IDMP:工业 AI 时代的平台新物种——AI-Ready的工业数据与模型平台
时序数据库·tdengine·实时数据库
TDengine (老段)5 天前
TDengine IDMP 可视化 —— 趋势图
大数据·数据库·人工智能·物联网·时序数据库·tdengine·涛思数据
涛思数据(TDengine)5 天前
以资产为核心的数据建模:工业数据上下文的基础|TDengine IDMP
时序数据库·tdengine·实时数据库
涛思数据(TDengine)5 天前
成本降 70%、查询<500ms、异常 2 秒响应:海螺信息用 TDengine 让水泥行业加速升级
时序数据库·tdengine·工业数据库
qq_391105346 天前
TDengine C# 连接示例和授权管理
大数据·数据库·c#·时序数据库·tdengine
TDengine (老段)6 天前
以事件为核心 + 以资产为核心:工业数据中缺失的关键一环
大数据·数据库·人工智能·时序数据库·tdengine·涛思数据
TDengine (老段)7 天前
TDengine IDMP 工业数据建模 —— 元素与数据查询
大数据·数据库·人工智能·物联网·时序数据库·tdengine·涛思数据