Schema Export

1. Overview

The schema export tool export-schema.sh/bat is located in the tools directory. It can export schema from a specified database in IoTDB to a script file.

2. Detailed Functionality

2.1 Parameter

Short ParamFull ParamDescriptionRequiredDefault
-h-- hostHostnameNo127.0.0.1
-p--portPort numberNo6667
-u--usernameUsernameNoroot
-pw--passwordPasswordNoroot
-sql_dialect--sql_dialectSpecifies whether the server usestree model ortable modelNotree
-db--databaseTarget database to export (only applies when-sql_dialect=table)Required if-sql_dialect=table-
-table--tableTarget table to export (only applies when-sql_dialect=table)No-
-t--targetOutput directory (created if it doesn't exist)Yes
-path--path_patternPath pattern for metadata exportRequired if-sql_dialect=tree
-pfn--prefix_file_nameOutput filename prefixNodump_dbname.sql
-lpf--lines_per_fileMaximum lines per dump file (only applies when-sql_dialect=tree)No10000
-timeout--query_timeoutQuery timeout in milliseconds (-1= no timeout)No-1Range:-1 to Long. max=9223372036854775807
-help--helpDisplay help informationNo

2.2 Command

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
# Before version 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 and later versions
> 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 Examples

# Export schema under root.treedb
./export-schema.sh -sql_dialect tree -t /home/ -path "root.treedb.**"

# Output
Timeseries,Alias,DataType,Encoding,Compression
root.treedb.device.temperature,,DOUBLE,GORILLA,LZ4
root.treedb.device.humidity,,DOUBLE,GORILLA,LZ4