Schema Import
May 15, 2025About 1 min
Schema Import
1. Overview
The schema import tool import-schema.sh/bat is located in tools directory.
2. Detailed Functionality
2.1 Parameter
| Short Param | Full Param | Description | Required | Default | 
|---|---|---|---|---|
-h | -- host | Hostname | No | 127.0.0.1 | 
-p | --port | Port number | No | 6667 | 
-u | --username | Username | No | root | 
-pw | --password | Password | No | root | 
-sql_dialect | --sql_dialect | Specifies whether the server usestree model ortable model | No | tree | 
-db | --database | Target database for import | Yes | - | 
-table | --table | Target table for import (only applies when-sql_dialect=table) | No | - | 
-s | --source | Local directory path containing script file(s) to import | Yes | |
-fd | --fail_dir | Directory to save failed import files | No | |
-lpf | --lines_per_failed_file | Maximum lines per failed file (only applies when-sql_dialect=table) | No | 100000Range:0 to Integer.Max=2147483647 | 
-help | --help | Display help information | No | 
2.2 Command
# Unix/OS X
tools/import-schema.sh [-sql_dialect<sql_dialect>] -db<database> -table<table> 
     [-h <host>] [-p <port>] [-u <username>] [-pw <password>]
       -s <source> [-fd <fail_dir>] [-lpf <lines_per_failed_file>]
      
# Windows
# Before version V2.0.4.x  
tools\import-schema.bat [-sql_dialect<sql_dialect>] -db<database> -table<table>  
      [-h <host>] [-p <port>] [-u <username>] [-pw <password>]
       -s <source> [-fd <fail_dir>] [-lpf <lines_per_failed_file>] 
       
# V2.0.4.x and later versions       
tools\windows\schema\import-schema.bat [-sql_dialect<sql_dialect>] -db<database> -table<table>  
      [-h <host>] [-p <port>] [-u <username>] [-pw <password>]
       -s <source> [-fd <fail_dir>] [-lpf <lines_per_failed_file>]2.3 Examples
# Before import
IoTDB> show timeseries root.treedb.**
+----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
|Timeseries|Alias|Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType|
+----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
+----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
# Execution
./import-schema.sh -sql_dialect tree -s /home/dump0_0.csv -db root.treedb
# Verification
IoTDB> show timeseries root.treedb.**
+------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+
|                    Timeseries|Alias|   Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType|
+------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+
|root.treedb.device.temperature| null|root.treedb|  DOUBLE| GORILLA|        LZ4|null|      null|    null|              null|    BASE|
|   root.treedb.device.humidity| null|root.treedb|  DOUBLE| GORILLA|        LZ4|null|      null|    null|              null|    BASE|
+------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+