Ray Shown
Ray Shown

Reputation: 31

how execute tdengine sql in shell script?

I was using tdengine, since I want to drop deprecated database through shell script. Is there any command that tdengine supports like hive can execute sql in command without CLI. Such as: execute sql script:

hive -f  mytest.sql

excute sql command

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

Can someone help ? THX.

Upvotes: 0

Views: 49

Answers (1)

GeorgeWill93
GeorgeWill93

Reputation: 167

You could use taos -s options to execute the command without entering 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)

Upvotes: 1

Related Questions