zoukankan      html  css  js  c++  java
  • [转]TDengine常用命令及SQL

    原文:https://blog.csdn.net/weixin_43700866/article/details/114646921

    -------------------------------------

    TDengine常用命令及SQL
    1.数据库基础命令
    1.1.数据库启停(RHEL/CentOS)
    1.2.查看服务端参数
    1.3.查看客户端参数
    1.4.客户端登录
    1.5.查看数据库参数
    2.节点管理
    2.1.查看数据节点
    2.2.查看管理节点
    2.3.添加数据节点
    2.4.删除数据节点
    3.用户管理
    3.1.添加用户
    3.2.删除用户
    3.3.查看用户
    3.4.修改用户密码
    3.5.修改用户权限
    4.数据库管理
    4.1.创建数据库
    4.2.删除数据库
    4.3.修改数据库参数
    4.4.查看vgroups
    5.表管理
    5.1.表管理
    5.2.超级表管理
    6.会话管理
    6.1.查看会话
    6.2.清理会话
    1.数据库基础命令
    1.1.数据库启停(RHEL/CentOS)
    systemctl start taosd
    systemctl stop taosd

    [root@ms05 ~]# systemctl start taosd
    [root@ms05 ~]# ps -ef | grep taosd
    root 7888 1 0 21:41 ? 00:00:00 /usr/bin/taosd
    root 7929 7830 0 21:42 pts/0 00:00:00 grep --color=auto taosd
    [root@ms05 ~]# systemctl stop taosd
    [root@ms05 ~]# ps -ef | grep taosd
    root 7938 7830 0 21:42 pts/0 00:00:00 grep --color=auto taosd
    1
    2
    3
    4
    5
    6
    7
    1.2.查看服务端参数
    taosd -C
    [root@ms05 ~]# taosd -C

    taos global config:
    ==================================
    serverPort: 6030
    arbitrator:
    numOfMnodes: 3
    vnodeBak: 1
    telemetryReporting: 1
    balance: 1
    balanceInterval: 300
    maxTmrCtrl: 512
    offlineThreshold: 8640000(s)
    statusInterval: 1(s)
    minSlidingTime: 10(ms)
    minIntervalTime: 10(ms)
    maxStreamCompDelay: 20000(ms)
    maxFirstStreamCompDelay:10000(ms)
    retryStreamCompDelay: 10(ms)
    streamCompDelayRatio: 0.100000
    maxVgroupsPerDb: 100
    maxTablesPerVnode: 400
    minTablesPerVnode: 10
    tableIncStepPerVnode: 1000
    cache: 16(Mb)
    blocks: 6
    days: 10
    keep: 3650
    minRows: 100
    maxRows: 4096
    comp: 2
    walLevel: 1
    fsync: 3000
    replica: 1
    quorum: 1
    update: 0
    compressMsgSize: -1
    maxSQLLength: 65480(byte)
    maxNumOfOrderedRes: 100000
    queryBufferSize: -1(byte)
    retrieveBlockingModel: 0
    keepColumnName: 0
    timezone:
    locale:
    charset:
    maxShellConns: 5000
    maxConnections: 5000
    minimalLogDirGB: 1.000000(GB)
    minimalTmpDirGB: 1.000000(GB)
    minimalDataDirGB: 1.000000(GB)
    mnodeEqualVnodeNum: 4
    flowctrl: 1
    slaveQuery: 1
    adjustMaster: 1
    http: 1
    mqtt: 0
    monitor: 1
    stream: 1
    telegrafUseFieldNum: 0
    gitinfo: 66eee02ce327c60553d44ec2c3f14e7feba78563
    gitinfoOfInternal: NULL
    buildinfo: Built at 2021-02-10 09:27
    version: 2.0.16.0

    taos local config:
    ==================================
    firstEp: ms06.dyq.com:6030
    secondEp:
    fqdn: ms05.dyq.com
    configDir: /etc/taos
    logDir: /var/log/taos
    scriptDir: /etc/taos
    numOfThreadsPerCore: 1.000000
    numOfCommitThreads: 1
    ratioOfQueryCores: 1.000000
    role: 0
    monitorInterval: 30(s)
    rpcTimer: 1000(ms)
    rpcMaxTime: 600(s)
    shellActivityTimer: 3(s)
    httpEnableRecordSql: 0
    httpMaxThreads: 2
    restfulRowLimit: 10240
    numOfLogLines: 10000000
    logKeepDays: 0
    asyncLog: 1
    debugFlag: 0
    mDebugFlag: 131
    dDebugFlag: 135
    sDebugFlag: 135
    wDebugFlag: 135
    sdbDebugFlag: 131
    rpcDebugFlag: 131
    tmrDebugFlag: 131
    cDebugFlag: 131
    jniDebugFlag: 131
    odbcDebugFlag: 131
    uDebugFlag: 131
    httpDebugFlag: 131
    mqttDebugFlag: 131
    monDebugFlag: 131
    qDebugFlag: 131
    vDebugFlag: 135
    tsdbDebugFlag: 131
    cqDebugFlag: 131
    enableRecordSql: 0
    enableCoreFile: 0
    maxBinaryDisplayWidth: 30
    tempDir: /tmp/
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    1.3.查看客户端参数
    taos -C

    [root@ms05 ~]# taos -C
    taos global config:
    ==================================
    serverPort: 6030
    arbitrator:
    compressMsgSize: -1
    maxSQLLength: 65480(byte)
    maxNumOfOrderedRes: 100000
    keepColumnName: 0
    timezone:
    locale:
    charset:
    gitinfo: 66eee02ce327c60553d44ec2c3f14e7feba78563
    gitinfoOfInternal: NULL
    buildinfo: Built at 2021-02-10 09:27
    version: 2.0.16.0

    taos local config:
    ==================================
    firstEp: ms06.dyq.com:6030
    secondEp:
    fqdn: ms05.dyq.com
    configDir: /etc/taos
    logDir: /var/log/taos
    scriptDir: /etc/taos
    numOfThreadsPerCore: 1.000000
    rpcTimer: 1000(ms)
    rpcMaxTime: 600(s)
    shellActivityTimer: 3(s)
    numOfLogLines: 10000000
    logKeepDays: 0
    asyncLog: 1
    debugFlag: 0
    rpcDebugFlag: 131
    tmrDebugFlag: 131
    cDebugFlag: 131
    jniDebugFlag: 131
    odbcDebugFlag: 131
    uDebugFlag: 131
    qDebugFlag: 131
    tsdbDebugFlag: 131
    maxBinaryDisplayWidth: 30
    tempDir: /tmp/
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    1.4.客户端登录
    toas

    [root@ms05 ~]# taos --help Usage: taos [OPTION…]

    -A, --user=Auth The user auth to use when connecting to the server.
    -c, --config-dir=CONFIG_DIR Configuration directory.
    -C, --dump-config Dump configuration.
    -d, --database=DATABASE Database to use when connecting to the server.
    -D, --directory=DIRECTORY Use multi-thread to import all SQL files in the directory separately.
    -f, --file=FILE Script to run without enter the shell.
    -h, --host=HOST TDengine server FQDN to connect. The default host is localhost.
    -l, --pktlen=PKTLEN Packet length used for net test, default is 1000 bytes.
    -n, --netrole=NETROLE Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync.
    -p, --password[=PASSWORD] The password to use when connecting to the server.
    -P, --port=PORT The TCP/IP port number to use for the connection.
    -r, --raw-time Output time as uint64_t.
    -s, --commands=COMMANDS Commands to run without enter the shell.
    -t, --timezone=TIMEZONE Time zone of the shell, default is local.
    -T, --thread=THREADNUM Number of threads when using multi-thread to import data.
    -u, --user=USER The user name to use when connecting to the server.
    -?, --help Give this help list
    –usage Give a short usage message
    -V, --version Print program version

    1.5.查看数据库参数
    show variables;

    taos> show variables;
    name | value |
    ============================================================
    version | 2.0.16.0 |
    buildinfo | Built at 2021-02-10 09:27 |
    gitinfoOfInternal | NULL |
    gitinfo | 66eee02ce327c60553d44ec2c3f... |
    telegrafUseFieldNum | 0 |
    stream | 1 |
    monitor | 1 |
    mqtt | 0 |
    http | 1 |
    adjustMaster | 1 |
    slaveQuery | 1 |
    flowctrl | 1 |
    mnodeEqualVnodeNum | 4 |
    minimalDataDirGB | 1.000000 |
    minimalTmpDirGB | 1.000000 |
    minimalLogDirGB | 1.000000 |
    maxConnections | 5000 |
    maxShellConns | 5000 |
    charset | UTF-8 |
    locale | en_US.UTF-8 |
    timezone | (CST, +0800) |
    keepColumnName | 0 |
    retrieveBlockingModel | 0 |
    queryBufferSize | -1 |
    maxNumOfOrderedRes | 100000 |
    maxSQLLength | 65480 |
    compressMsgSize | -1 |
    update | 0 |
    quorum | 1 |
    replica | 1 |
    fsync | 3000 |
    walLevel | 1 |
    comp | 2 |
    maxRows | 4096 |
    minRows | 100 |
    keep | 3650 |
    days | 10 |
    blocks | 6 |
    cache | 16 |
    tableIncStepPerVnode | 1000 |
    minTablesPerVnode | 10 |
    maxTablesPerVnode | 400 |
    maxVgroupsPerDb | 100 |
    streamCompDelayRatio | 0.100000 |
    retryStreamCompDelay | 10 |
    maxFirstStreamCompDela | 10000 |
    maxStreamCompDelay | 20000 |
    minIntervalTime | 10 |
    minSlidingTime | 10 |
    statusInterval | 1 |
    offlineThreshold | 8640000 |
    maxTmrCtrl | 512 |
    balanceInterval | 300 |
    balance | 1 |
    telemetryReporting | 1 |
    vnodeBak | 1 |
    numOfMnodes | 3 |
    arbitrator | |
    serverPort | 6030 |
    Query OK, 59 row(s) in set (0.002253s)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    2.节点管理
    2.1.查看数据节点
    show dnodes;

    taos> show dnodes;
    id | end_point | vnodes | cores | status | role | create_time | offline reason |
    ======================================================================================================================================
    1 | ms06.dyq.com:6030 | 0 | 4 | ready | any | 2021-03-06 14:01:42.957 | |
    2 | ms07.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-06 14:02:46.594 | |
    3 | ms08.dyq.com:6030 | 2 | 4 | ready | any | 2021-03-06 14:03:27.454 | |
    4 | ms09.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-06 14:03:28.316 | |
    Query OK, 4 row(s) in set (0.001141s)
    1
    2
    3
    4
    5
    6
    7
    8
    2.2.查看管理节点
    show mondes;

    taos> show mnodes;
    id | end_point | role | create_time |
    ===================================================================================
    1 | ms06.dyq.com:6030 | master | 2021-03-06 14:01:42.957 |
    2 | ms07.dyq.com:6030 | slave | 2021-03-06 14:02:47.209 |
    4 | ms09.dyq.com:6030 | slave | 2021-03-06 14:03:50.659 |
    Query OK, 3 row(s) in set (0.001554s)
    1
    2
    3
    4
    5
    6
    7
    2.3.添加数据节点
    create dnode “ms05.dyq.com:6030” ;

    taos> create dnode "ms05.dyq.com:6030" ;
    Query OK, 0 row(s) affected (0.002531s)

    taos> show dnodes;
    id | end_point | vnodes | cores | status | role | create_time | offline reason |
    ======================================================================================================================================
    1 | ms06.dyq.com:6030 | 0 | 4 | ready | any | 2021-03-06 14:01:42.957 | |
    2 | ms07.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-06 14:02:46.594 | |
    3 | ms08.dyq.com:6030 | 2 | 4 | ready | any | 2021-03-06 14:03:27.454 | |
    4 | ms09.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-06 14:03:28.316 | |
    10 | ms05.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-10 22:08:56.142 | |
    Query OK, 5 row(s) in set (0.001233s)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    要添加新节点,需要节点间以下参数相同:
    numOfMnodes:系统中管理节点个数。默认值:3。 balance:是否启动负载均衡。0:否,1:是。默认值:1。
    mnodeEqualVnodeNum: 一个mnode等同于vnode消耗的个数。默认值:4。 offlineThreshold:>
    dnode离线阈值,超过该时间将导致该dnode从集群中删除。单位为秒,默认值:86400*10(即10天)。
    statusInterval: dnode向mnode报告状态时长。单位为秒,默认值:1。 maxTablesPerVnode:>
    每个vnode中能够创建的最大表个数。默认值:1000000。 maxVgroupsPerDb:>
    每个数据库中能够使用的最大vgroup个数。 arbitrator: 系统中裁决器的end point,缺省为空。
    timezone、locale、charset 的配置见客户端配置。 以上描述来自TDengine官方文档

    2.4.删除数据节点
    drop dnode “ms05.dyq.com:6030”;

    taos> drop dnode "ms05.dyq.com:6030";
    Query OK, 0 row(s) affected (0.000480s)

    taos> show dnodes;
    id | end_point | vnodes | cores | status | role | create_time | offline reason |
    ======================================================================================================================================
    1 | ms06.dyq.com:6030 | 0 | 4 | ready | any | 2021-03-06 14:01:42.957 | |
    2 | ms07.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-06 14:02:46.594 | |
    3 | ms08.dyq.com:6030 | 2 | 4 | ready | any | 2021-03-06 14:03:27.454 | |
    4 | ms09.dyq.com:6030 | 1 | 4 | ready | any | 2021-03-06 14:03:28.316 | |
    10 | ms05.dyq.com:6030 | 0 | 4 | dropping | any | 2021-03-10 22:08:56.142 | |
    Query OK, 5 row(s) in set (0.001767s)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    3.用户管理
    3.1.添加用户
    create user test1 pass ‘test1’;

    创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角

    3.2.删除用户
    drop user test1;

    3.3.查看用户
    show users;

    3.4.修改用户密码
    alter user test1 pass ‘test2’;

    3.5.修改用户权限
    alter user test1 privilege read;

    系统内共有 super/write/read 三种权限级别,但不允许把 super 权限赋予用户。

    taos> create user test1 pass 'test1';
    Query OK, 0 row(s) affected (0.002419s)

    taos> show users;
    name | privilege | create_time | account |
    ============================================================================================
    _root | writable | 2021-03-06 14:01:42.958 | root |
    test | writable | 2021-03-10 21:49:59.992 | root |
    monitor | writable | 2021-03-06 14:01:42.958 | root |
    test1 | writable | 2021-03-10 22:16:34.549 | root |
    root | super | 2021-03-06 14:01:42.958 | root |
    Query OK, 5 row(s) in set (0.001649s)

    taos> alter user test1 pass 'test2';
    Query OK, 0 row(s) affected (0.002351s)

    taos> alter user test1 privilege read;
    Query OK, 0 row(s) affected (0.002388s)

    taos> show users;
    name | privilege | create_time | account |
    ============================================================================================
    _root | writable | 2021-03-06 14:01:42.958 | root |
    test | writable | 2021-03-10 21:49:59.992 | root |
    monitor | writable | 2021-03-06 14:01:42.958 | root |
    test1 | readable | 2021-03-10 22:16:34.549 | root |
    root | super | 2021-03-06 14:01:42.958 | root |
    Query OK, 5 row(s) in set (0.001606s)

    taos> drop user test1;
    Query OK, 0 row(s) affected (0.002834s)

    taos> show users;
    name | privilege | create_time | account |
    ============================================================================================
    _root | writable | 2021-03-06 14:01:42.958 | root |
    test | writable | 2021-03-10 21:49:59.992 | root |
    monitor | writable | 2021-03-06 14:01:42.958 | root |
    root | super | 2021-03-06 14:01:42.958 | root |
    Query OK, 4 row(s) in set (0.001404s)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    4.数据库管理
    4.1.创建数据库
    create database testdb replica 3 keep 30 days 7 blocks 4 update 1;

    taos> create database testdb replica 3 keep 30 days 7 blocks 4 update 1;
    Query OK, 0 row(s) affected (0.003397s)

    taos> show databasesG;
    ......
    *************************** 3.row ***************************
    name: testdb
    created_time: 2021-03-10 22:24:10.014
    ntables: 0
    vgroups: 0
    replica: 3
    quorum: 1
    days: 7
    keep0,keep1,keep(D): 30,30,30
    cache(MB): 16
    blocks: 4
    minrows: 100
    maxrows: 4096
    wallevel: 1
    fsync: 3000
    comp: 2
    cachelast: 0
    precision: ms
    update: 1
    status: ready
    Query OK, 3 row(s) in set (0.001967s)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    replica: 数据副本数量,缺省值为 1,取值范围 [1, 3],值必须小于数据节点数量 keep: 数据保持最长天数,缺省值为
    3650,超过期限数据库会自动删除数据。最大值365000,但必须大于days值 days: 一个数据文件中存储几天的数据,缺省值为10
    comp: 是否压缩,缺省值为 2,取值范围为 [0, 2]。0 表示不压缩,1 表示一阶段压缩,2 表示两阶段压缩。 quorum:
    参数是指数据写入成功所需要的确认数,取值范围 [1, 3]。对于异步复制,quorum 设为 1,具有 master
    角色的虚拟节点自己确认即可。对于同步复制,需要至少大于等于 2。原则上,Quorum >= 1 并且 Quorum <=
    replica(副本数)。 blocks: 每个 VNODE 中有多少 cache 大小的内存块,因此一个 VNODE
    的用的内存大小粗略为(cache * blocks)。缺省值为6,取值范围 [3, 1000]。 cachelast:
    控制是否在内存中缓存数据子表的 last_row。缺省值为 0,取值范围 [0, 1]。其中 0 表示不启用、1 表示启用。
    update:是否更新相同时间戳数据,缺省值为0。0为不更新相同时间戳数据。

    4.2.删除数据库
    drop database test;

    4.3.修改数据库参数
    alter database testdb comp 1;
    alter database testdb replica 2;
    alter database testdb keep 365;
    alter database testdb quorum 2;
    alter database testdb blocks 100;
    alter database testdb cachelast 1;

    taos> alter database testdb comp 1;
    Query OK, 0 row(s) affected (0.002702s)

    taos> alter database testdb replica 2;
    Query OK, 0 row(s) affected (0.001466s)

    taos> alter database testdb keep 365;
    Query OK, 0 row(s) affected (0.001333s)

    taos> alter database testdb quorum 2;
    Query OK, 0 row(s) affected (0.001192s)

    taos> alter database testdb blocks 100;
    Query OK, 0 row(s) affected (0.001209s)

    taos> alter database testdb cachelast 1;
    Query OK, 0 row(s) affected (0.002577s)

    taos> show databasesG;
    ......
    *************************** 3.row ***************************
    name: testdb
    created_time: 2021-03-10 22:24:10.014
    ntables: 0
    vgroups: 0
    replica: 2
    quorum: 2
    days: 7
    keep0,keep1,keep(D): 30,30,365
    cache(MB): 16
    blocks: 100
    minrows: 100
    maxrows: 4096
    wallevel: 1
    fsync: 3000
    comp: 1
    cachelast: 1
    precision: ms
    update: 1
    status: ready
    Query OK, 3 row(s) in set (0.002026s)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    4.4.查看vgroups
    show vgroups;

    查看vgroups必须先进入具体数据库下

    taos> use test;
    Database changed.

    taos> show vgroups;
    vgId | tables | status | onlines | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status |
    ==========================================================================================================================
    134 | 1 | ready | 3 | 4 | master | 2 | slave | 3 | slave |
    Query OK, 1 row(s) in set (0.001748s)
    1
    2
    3
    4
    5
    6
    7
    8
    5.表管理
    语法与MySQL类似,不再赘述。

    5.1.表管理
    创建表
    use testdb;
    create table t1 (ts TIMESTAMP,name1 BINARY(100)) ;

    查看表结构
    describe t1;

    插入数据
    insert into t1 values(‘2021-03-10 22:37:36.100’,‘test’);

    查询表
    select * from t1;

    查看当前所有表
    show tables;

    taos> use testdb;
    Database changed.

    taos> create table t1 (ts TIMESTAMP,name1 BINARY(100)) ;
    Query OK, 0 row(s) affected (0.337263s)

    taos> describe t1;
    Field | Type | Length | Note |
    =================================================================================
    ts | TIMESTAMP | 8 | |
    name1 | BINARY | 100 | |
    Query OK, 2 row(s) in set (0.001216s)

    taos> insert into t1 values('2021-03-10 22:37:36.100','test');
    Query OK, 1 row(s) affected (0.000996s)

    taos> select * from t1;
    ts | name1 |
    ===========================================================
    2021-03-10 22:37:36.100 | test |
    Query OK, 1 row(s) in set (0.003716s)

    taos> show tablesG;
    *************************** 1.row ***************************
    table_name: t1
    created_time: 2021-03-10 22:50:35.576
    columns: 2
    stable_name:
    uid: 37999121874405271
    tid: 1
    vgId: 135
    Query OK, 1 row(s) in set (0.002383s)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    5.2.超级表管理
    创建超级表
    use testdb;
    create table st1 (ts TIMESTAMP,name1 BINARY(100)) tags (tgs binary(20));

    查看超级表结构
    describe st1;

    插入数据
    insert into t2 using st1 tags(‘tt’) values(‘2021-03-10 22:37:36.100’,‘test’);

    查询超级表
    select * from t1;

    查看当前所有超级表
    show stables;

    taos> use testdb;
    Database changed.

    taos> create table st1 (ts TIMESTAMP,name1 BINARY(100)) tags (tgs binary(20));
    Query OK, 0 row(s) affected (0.002633s)

    taos> describe st1;
    Field | Type | Length | Note |
    =================================================================================
    ts | TIMESTAMP | 8 | |
    name1 | BINARY | 100 | |
    tgs | BINARY | 20 | TAG |
    Query OK, 3 row(s) in set (0.001394s)

    taos> insert into t2 using st1 tags('tt') values('2021-03-10 22:37:36.100','test');
    Query OK, 1 row(s) affected (0.005681s)

    taos> show stablesG;
    *************************** 1.row ***************************
    name: st1
    created_time: 2021-03-10 22:56:31.660
    columns: 2
    tags: 1
    tables: 1
    Query OK, 1 row(s) in set (0.001225s)

    taos> show tablesG;
    *************************** 1.row ***************************
    table_name: t1
    created_time: 2021-03-10 22:50:35.576
    columns: 2
    stable_name:
    uid: 37999121874405271
    tid: 1
    vgId: 135
    *************************** 2.row ***************************
    table_name: t2
    created_time: 2021-03-10 22:58:38.758
    columns: 2
    stable_name: st1
    uid: 37999121891183092
    tid: 2
    vgId: 135
    Query OK, 2 row(s) in set (0.002557s)

    taos> select * from st1;
    ts | name1 | tgs |
    ==================================================================================
    2021-03-10 22:37:36.100 | test | tt |
    Query OK, 1 row(s) in set (0.030868s)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    6.会话管理
    6.1.查看会话
    show connections;

    6.2.清理会话
    kill connection 23;

    taos> show connections;
    connId | user | program | pid | ip:port | login_time | last_access |
    ===============================================================================================================================================================
    1 | monitor | taosd | 5715 | 192.168.1.79:42760 | 2021-03-10 21:35:22.903 | 2021-03-10 23:04:04.601 |
    2 | monitor | taosd | 5880 | 192.168.1.76:36500 | 2021-03-10 21:35:23.466 | 2021-03-10 23:04:05.225 |
    3 | monitor | taosd | 5791 | 192.168.1.78:46854 | 2021-03-10 21:35:23.575 | 2021-03-10 23:04:05.284 |
    4 | monitor | taosd | 5856 | 192.168.1.77:61739 | 2021-03-10 21:35:24.439 | 2021-03-10 23:04:04.633 |
    18 | root | taos | 6464 | 192.168.1.76:33928 | 2021-03-10 21:57:16.695 | 2021-03-10 23:04:05.088 |
    23 | root | taos | 8702 | 192.168.1.75:42408 | 2021-03-10 23:03:51.391 | 2021-03-10 23:04:04.919 |
    Query OK, 6 row(s) in set (0.001725s)

    taos> kill connection 23;
    Query OK, 0 row(s) in set (0.000602s)

    taos> show connections;
    connId | user | program | pid | ip:port | login_time | last_access |
    ===============================================================================================================================================================
    1 | monitor | taosd | 5715 | 192.168.1.79:42760 | 2021-03-10 21:35:22.903 | 2021-03-10 23:05:47.176 |
    2 | monitor | taosd | 5880 | 192.168.1.76:36500 | 2021-03-10 21:35:23.466 | 2021-03-10 23:05:46.255 |
    3 | monitor | taosd | 5791 | 192.168.1.78:46854 | 2021-03-10 21:35:23.575 | 2021-03-10 23:05:46.354 |
    4 | monitor | taosd | 5856 | 192.168.1.77:61739 | 2021-03-10 21:35:24.439 | 2021-03-10 23:05:47.223 |
    18 | root | taos | 6464 | 192.168.1.76:33928 | 2021-03-10 21:57:16.695 | 2021-03-10 23:05:46.122 |
    Query OK, 5 row(s) in set (0.001582s)
    ————————————————
    版权声明:本文为CSDN博主「DBA大董」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/weixin_43700866/article/details/114646921

  • 相关阅读:
    CCF201604试题
    CCF201512试题
    CCF201509试题
    CCF201509试题
    CCF201503试题
    CCF201503试题
    CCF201412试题
    CCF201412试题
    CCF201409试题
    CCF201409试题
  • 原文地址:https://www.cnblogs.com/oxspirt/p/15078944.html
Copyright © 2011-2022 走看看