如何在shell脚本中执行tdengine sql?

how execute tdengine sql in shell script?

我正在使用 tdengine,因为我想通过 shell 脚本删除已弃用的数据库。是否有 tdengine 支持的任何命令,如 hive 可以在没有 CLI 的情况下在命令中执行 sql。 如: 执行sql脚本:

hive -f  mytest.sql

执行sql命令

hive -e "use ${database};select * from tb"

有人可以帮忙吗?谢谢。

您可以使用 taos -s 选项来执行命令而无需输入 shell:

gavin@localhost$ taos -s "show databases"

Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.

taos> show databases
              name              |      created_time       |   ntables   |   vgroups   | replica | quorum |  days  |           keep           |  cache(MB)  |   blocks    |   minrows   |   maxrows   | wallevel |    fsync    | comp | cachelast | precision | update |   status   |
====================================================================================================================================================================================================================================================================================
 test                           | 2022-01-19 19:13:29.047 |           1 |           1 |       1 |      1 |     10 | 3650                     |          16 |           6 |         100 |        4096 |        1 |        3000 |    2 |         0 | ms        |      0 | ready      |
 log                            | 2022-01-04 16:03:49.325 |          11 |           1 |       1 |      1 |     10 | 30                       |           1 |           3 |         100 |        4096 |        1 |        3000 |    2 |         0 | us        |      0 | ready      |
Query OK, 2 row(s) in set (0.003306s)