元数据导出

1. 功能概述

元数据导出工具 export-schema.sh/bat 位于tools 目录下,能够将 IoTDB 中指定数据库下的元数据导出为脚本文件。

2. 功能详解

2.1 参数介绍

参数缩写参数全称参数含义是否为必填项默认值
-h-- host主机名127.0.0.1
-p--port端口号6667
-u--username用户名root
-pw--password密码TimechoDB@2021 (V2.0.6.x 版本之前为 root)
-sql_dialect--sql_dialect选择 server 是树模型还是表模型,当前支持 tree 和 table 类型tree
-db--database将要导出的目标数据库,只在-sql_dialect为 table 类型下生效。-sql_dialect为 table 时必填-
-table--table将要导出的目标表,只在-sql_dialect为 table 类型下生效。-
-t--target指定输出文件的目标文件夹,如果路径不存在新建文件夹
-path--path_pattern指定导出元数据的path pattern-sql_dialect为 tree 时必填
-pfn--prefix_file_name指定导出文件的名称。dump_dbname.sql
-lpf--lines_per_file指定导出的dump文件最大行数,只在-sql_dialect为 tree 类型下生效。10000
-timeout--query_timeout会话查询的超时时间(ms)-1范围:-1~Long. max=9223372036854775807
-help--help显示帮助信息

2.2 运行命令

Shell
# Unix/OS X
> tools/export-schema.sh [-sql_dialect<sql_dialect>] -db<database> -table<table>  
                [-h <host>] [-p <port>] [-u <username>] [-pw <password>] 
                -t <target_directory> [-path <exportPathPattern>] [-pfn <prefix_file_name>] 
                [-lpf <lines_per_file>] [-timeout <query_timeout>]
# Windows
# V2.0.4.x 版本之前
> tools\export-schema.bat [-sql_dialect<sql_dialect>] -db<database> -table<table>  
                [-h <host>] [-p <port>] [-u <username>] [-pw <password>] 
                -t <target_directory> [-path <exportPathPattern>] [-pfn <prefix_file_name>] 
                [-lpf <lines_per_file>] [-timeout <query_timeout>]
               
# V2.0.4.x 版本及之后               
> tools\windows\schema\export-schema.bat [-sql_dialect<sql_dialect>] -db<database> -table<table>  
                [-h <host>] [-p <port>] [-u <username>] [-pw <password>] 
                -t <target_directory> [-path <exportPathPattern>] [-pfn <prefix_file_name>] 
                [-lpf <lines_per_file>] [-timeout <query_timeout>]

2.3 运行示例

# 导出 root.treedb路径下的元数据
./export-schema.sh -sql_dialect tree -t /home/ -path "root.treedb.**"

# 导出结果内容格式如下
Timeseries,Alias,DataType,Encoding,Compression
root.treedb.device.temperature,,DOUBLE,GORILLA,LZ4
root.treedb.device.humidity,,DOUBLE,GORILLA,LZ4