diff --git a/src/.vuepress/sidebar/V2.0.x/en-Table.ts b/src/.vuepress/sidebar/V2.0.x/en-Table.ts index 63272d441..97e3e5a46 100644 --- a/src/.vuepress/sidebar/V2.0.x/en-Table.ts +++ b/src/.vuepress/sidebar/V2.0.x/en-Table.ts @@ -120,8 +120,18 @@ export const enSidebar = { { text: 'Monitor Tool', link: 'Monitor-Tool_apache' }, { text: 'Benchmark Tool', link: 'Benchmark' }, { text: 'Cluster Management Tool', link: 'Maintenance-Tool_apache' }, - { text: 'Data Import', link: 'Data-Import-Tool' }, - { text: 'Data Export', link: 'Data-Export-Tool' }, + { text: 'Data Import & Export', collapsible: true, + children: [ + { text: 'Data Import', link: 'Data-Import-Tool' }, + { text: 'Data Export', link: 'Data-Export-Tool' }, + ], + }, + { text: 'Schema Import & Export', collapsible: true, + children: [ + { text: 'Schema Import', link: 'Schema-Import-Tool' }, + { text: 'Schema Export', link: 'Schema-Export-Tool' }, + ], + }, ], }, { diff --git a/src/.vuepress/sidebar/V2.0.x/en-Tree.ts b/src/.vuepress/sidebar/V2.0.x/en-Tree.ts index 72ed3b7e4..d082a176b 100644 --- a/src/.vuepress/sidebar/V2.0.x/en-Tree.ts +++ b/src/.vuepress/sidebar/V2.0.x/en-Tree.ts @@ -143,8 +143,18 @@ export const enSidebar = { { text: 'Monitor Tool', link: 'Monitor-Tool_apache' }, { text: 'Benchmark Tool', link: 'Benchmark' }, { text: 'Cluster Management Tool', link: 'Maintenance-Tool_apache' }, - { text: 'Data Import', link: 'Data-Import-Tool' }, - { text: 'Data Export', link: 'Data-Export-Tool' }, + { text: 'Data Import & Export', collapsible: true, + children: [ + { text: 'Data Import', link: 'Data-Import-Tool' }, + { text: 'Data Export', link: 'Data-Export-Tool' }, + ], + }, + { text: 'Schema Import & Export', collapsible: true, + children: [ + { text: 'Schema Import', link: 'Schema-Import-Tool' }, + { text: 'Schema Export', link: 'Schema-Export-Tool' }, + ], + }, { text: 'Full Backup Tool', link: 'Backup-Tool' }, { text: 'Health Check Tool', link: 'Health-Check-Tool' }, ], diff --git a/src/.vuepress/sidebar/V2.0.x/zh-Table.ts b/src/.vuepress/sidebar/V2.0.x/zh-Table.ts index e4f957898..1a42383db 100644 --- a/src/.vuepress/sidebar/V2.0.x/zh-Table.ts +++ b/src/.vuepress/sidebar/V2.0.x/zh-Table.ts @@ -110,8 +110,18 @@ export const zhSidebar = { { text: '命令行工具', link: 'CLI' }, { text: '监控工具', link: 'Monitor-Tool_apache' }, { text: '集群管理工具', link: 'Maintenance-Tool_apache' }, - { text: '数据导入', link: 'Data-Import-Tool' }, - { text: '数据导出', link: 'Data-Export-Tool' }, + { text: '数据导入导出', collapsible: true, + children: [ + { text: '数据导入', link: 'Data-Import-Tool' }, + { text: '数据导出', link: 'Data-Export-Tool' }, + ], + }, + { text: '元数据导入导出', collapsible: true, + children: [ + { text: '元数据导入', link: 'Schema-Import-Tool' }, + { text: '元数据导出', link: 'Schema-Export-Tool' }, + ], + }, ], }, { diff --git a/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts b/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts index e32c1d96f..9d17be6c6 100644 --- a/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts +++ b/src/.vuepress/sidebar/V2.0.x/zh-Tree.ts @@ -132,8 +132,18 @@ export const zhSidebar = { { text: '监控工具', link: 'Monitor-Tool_apache' }, { text: '测试工具', link: 'Benchmark' }, { text: '集群管理工具', link: 'Maintenance-Tool_apache' }, - { text: '数据导入', link: 'Data-Import-Tool' }, - { text: '数据导出', link: 'Data-Export-Tool' }, + { text: '数据导入导出', collapsible: true, + children: [ + { text: '数据导入', link: 'Data-Import-Tool' }, + { text: '数据导出', link: 'Data-Export-Tool' }, + ], + }, + { text: '元数据导入导出', collapsible: true, + children: [ + { text: '元数据导入', link: 'Schema-Import-Tool' }, + { text: '元数据导出', link: 'Schema-Export-Tool' }, + ], + }, { text: '全量备份工具', link: 'Backup-Tool' }, { text: '健康检查工具', link: 'Health-Check-Tool' }, ], diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts b/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts index 2e411665c..73704e2b5 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts @@ -125,8 +125,18 @@ export const enSidebar = { { text: 'Monitor Tool', link: 'Monitor-Tool_timecho' }, { text: 'Benchmark Tool', link: 'Benchmark' }, { text: 'Cluster Management Tool', link: 'Maintenance-Tool_timecho' }, - { text: 'Data Import', link: 'Data-Import-Tool' }, - { text: 'Data Export', link: 'Data-Export-Tool' }, + { text: 'Data Import & Export', collapsible: true, + children: [ + { text: 'Data Import', link: 'Data-Import-Tool' }, + { text: 'Data Export', link: 'Data-Export-Tool' }, + ], + }, + { text: 'Schema Import & Export', collapsible: true, + children: [ + { text: 'Schema Import', link: 'Schema-Import-Tool' }, + { text: 'Schema Export', link: 'Schema-Export-Tool' }, + ], + }, ], }, { diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts b/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts index 8b5d59e32..8c318c8ad 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts @@ -159,8 +159,18 @@ export const enSidebar = { { text: 'Monitor Tool', link: 'Monitor-Tool_timecho' }, { text: 'Benchmark Tool', link: 'Benchmark' }, { text: 'Cluster Management Tool', link: 'Maintenance-Tool_timecho' }, - { text: 'Data Import', link: 'Data-Import-Tool' }, - { text: 'Data Export', link: 'Data-Export-Tool' }, + { text: 'Data Import & Export', collapsible: true, + children: [ + { text: 'Data Import', link: 'Data-Import-Tool' }, + { text: 'Data Export', link: 'Data-Export-Tool' }, + ], + }, + { text: 'Schema Import & Export', collapsible: true, + children: [ + { text: 'Schema Import', link: 'Schema-Import-Tool' }, + { text: 'Schema Export', link: 'Schema-Export-Tool' }, + ], + }, { text: 'Full Backup Tool', link: 'Backup-Tool' }, { text: 'Health Check Tool', link: 'Health-Check-Tool' }, ], diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts index 3a5d4e426..739fc076d 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts @@ -114,8 +114,18 @@ export const zhSidebar = { { text: '监控工具', link: 'Monitor-Tool_timecho' }, { text: '测试工具', link: 'Benchmark' }, { text: '集群管理工具', link: 'Maintenance-Tool_timecho' }, - { text: '数据导入', link: 'Data-Import-Tool' }, - { text: '数据导出', link: 'Data-Export-Tool' }, + { text: '数据导入导出', collapsible: true, + children: [ + { text: '数据导入', link: 'Data-Import-Tool' }, + { text: '数据导出', link: 'Data-Export-Tool' }, + ], + }, + { text: '元数据导入导出', collapsible: true, + children: [ + { text: '元数据导入', link: 'Schema-Import-Tool' }, + { text: '元数据导出', link: 'Schema-Export-Tool' }, + ], + }, ], }, { diff --git a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts index c3ca85fd1..0c16a33f7 100644 --- a/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts +++ b/src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts @@ -142,8 +142,18 @@ export const zhSidebar = { { text: '监控工具', link: 'Monitor-Tool_timecho' }, { text: '测试工具', link: 'Benchmark' }, { text: '集群管理工具', link: 'Maintenance-Tool_timecho' }, - { text: '数据导入', link: 'Data-Import-Tool' }, - { text: '数据导出', link: 'Data-Export-Tool' }, + { text: '数据导入导出', collapsible: true, + children: [ + { text: '数据导入', link: 'Data-Import-Tool' }, + { text: '数据导出', link: 'Data-Export-Tool' }, + ], + }, + { text: '元数据导入导出', collapsible: true, + children: [ + { text: '元数据导入', link: 'Schema-Import-Tool' }, + { text: '元数据导出', link: 'Schema-Export-Tool' }, + ], + }, { text: '全量备份工具', link: 'Backup-Tool' }, { text: '健康检查工具', link: 'Health-Check-Tool' }, ], diff --git a/src/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md b/src/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..185514f25 --- /dev/null +++ b/src/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,101 @@ + + +# 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 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 uses`tree `model or`table `model | No | tree | +| `-db` | `--database` | Target database to export (only applies when`-sql_dialect=table`) | Required if`-sql_dialect=table` | - | +| `-table` | `--table` | Target table to export (only applies when`-sql_dialect=table`) | No | - | +| `-t` | `--target` | Output directory (created if it doesn't exist) | Yes | | +| `-path` | `--path_pattern` | Path pattern for metadata export | Required if`-sql_dialect=tree` | | +| `-pfn` | `--prefix_file_name` | Output filename prefix | No | `dump_dbname.sql` | +| `-lpf` | `--lines_per_file` | Maximum lines per dump file (only applies when`-sql_dialect=tree`) | No | `10000` | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (`-1`= no timeout) | No | -1Range:`-1 to Long. max=9223372036854775807` | +| `-help` | `--help` | Display help information | No | | + +### 2.2 Command + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table + [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 Examples + +Export schema from `database1` to `/home`: + +```Bash +./export-schema.sh -sql_dialect table -t /home/ -db database1 +``` + +Output `dump_database1.sql`: + +```sql +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` diff --git a/src/UserGuide/Master/Table/Tools-System/Schema-Import-Tool.md b/src/UserGuide/Master/Table/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..94fb11246 --- /dev/null +++ b/src/UserGuide/Master/Table/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,157 @@ + + +# 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 uses`tree `model or`table `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 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 Examples + +Import `dump_database1.sql` from `/home` into `database2`, + +```sql +-- File content (dump_database1.sql): +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` + +Executing the command: + +```Bash +./import-schema.sh -sql_dialect table -s /home/dump_database1.sql -db database2 + +# If database2 doesn't exist +The target database database2 does not exist + +# If database2 exists +Import completely! +``` + +Verification: + +```Bash +# Before import +IoTDB:database2> show tables ++---------+-------+ +|TableName|TTL(ms)| ++---------+-------+ ++---------+-------+ +Empty set. + +# After import +IoTDB:database2> show tables details ++---------+-------+------+-------+ +|TableName|TTL(ms)|Status|Comment| ++---------+-------+------+-------+ +| table2| INF| USING| null| +| table1| INF| USING| null| ++---------+-------+------+-------+ + +IoTDB:database2> desc table1 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ + +IoTDB:database2> desc table2 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ +``` diff --git a/src/UserGuide/Master/Tree/Tools-System/Schema-Export-Tool.md b/src/UserGuide/Master/Tree/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..7e11b9d3a --- /dev/null +++ b/src/UserGuide/Master/Tree/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,75 @@ + + +# 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 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 uses`tree `model or`table `model | No | tree | +| `-db` | `--database` | Target database to export (only applies when`-sql_dialect=table`) | Required if`-sql_dialect=table` | - | +| `-table` | `--table` | Target table to export (only applies when`-sql_dialect=table`) | No | - | +| `-t` | `--target` | Output directory (created if it doesn't exist) | Yes | | +| `-path` | `--path_pattern` | Path pattern for metadata export | Required if`-sql_dialect=tree` | | +| `-pfn` | `--prefix_file_name` | Output filename prefix | No | `dump_dbname.sql` | +| `-lpf` | `--lines_per_file` | Maximum lines per dump file (only applies when`-sql_dialect=tree`) | No | `10000` | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (`-1`= no timeout) | No | -1Range:`-1 to Long. max=9223372036854775807` | +| `-help` | `--help` | Display help information | No | | + +### 2.2 Command + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 Examples + + +```Bash +# 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 +``` \ No newline at end of file diff --git a/src/UserGuide/Master/Tree/Tools-System/Schema-Import-Tool.md b/src/UserGuide/Master/Tree/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..d4a1aa68d --- /dev/null +++ b/src/UserGuide/Master/Tree/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,81 @@ + + +# 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 uses`tree `model or`table `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 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 Examples + +```Bash +# 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| ++------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+ +``` diff --git a/src/UserGuide/latest-Table/Tools-System/Schema-Export-Tool.md b/src/UserGuide/latest-Table/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..185514f25 --- /dev/null +++ b/src/UserGuide/latest-Table/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,101 @@ + + +# 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 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 uses`tree `model or`table `model | No | tree | +| `-db` | `--database` | Target database to export (only applies when`-sql_dialect=table`) | Required if`-sql_dialect=table` | - | +| `-table` | `--table` | Target table to export (only applies when`-sql_dialect=table`) | No | - | +| `-t` | `--target` | Output directory (created if it doesn't exist) | Yes | | +| `-path` | `--path_pattern` | Path pattern for metadata export | Required if`-sql_dialect=tree` | | +| `-pfn` | `--prefix_file_name` | Output filename prefix | No | `dump_dbname.sql` | +| `-lpf` | `--lines_per_file` | Maximum lines per dump file (only applies when`-sql_dialect=tree`) | No | `10000` | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (`-1`= no timeout) | No | -1Range:`-1 to Long. max=9223372036854775807` | +| `-help` | `--help` | Display help information | No | | + +### 2.2 Command + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 Examples + +Export schema from `database1` to `/home`: + +```Bash +./export-schema.sh -sql_dialect table -t /home/ -db database1 +``` + +Output `dump_database1.sql`: + +```sql +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` diff --git a/src/UserGuide/latest-Table/Tools-System/Schema-Import-Tool.md b/src/UserGuide/latest-Table/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..94fb11246 --- /dev/null +++ b/src/UserGuide/latest-Table/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,157 @@ + + +# 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 uses`tree `model or`table `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 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 Examples + +Import `dump_database1.sql` from `/home` into `database2`, + +```sql +-- File content (dump_database1.sql): +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` + +Executing the command: + +```Bash +./import-schema.sh -sql_dialect table -s /home/dump_database1.sql -db database2 + +# If database2 doesn't exist +The target database database2 does not exist + +# If database2 exists +Import completely! +``` + +Verification: + +```Bash +# Before import +IoTDB:database2> show tables ++---------+-------+ +|TableName|TTL(ms)| ++---------+-------+ ++---------+-------+ +Empty set. + +# After import +IoTDB:database2> show tables details ++---------+-------+------+-------+ +|TableName|TTL(ms)|Status|Comment| ++---------+-------+------+-------+ +| table2| INF| USING| null| +| table1| INF| USING| null| ++---------+-------+------+-------+ + +IoTDB:database2> desc table1 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ + +IoTDB:database2> desc table2 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ +``` diff --git a/src/UserGuide/latest/Tools-System/Schema-Export-Tool.md b/src/UserGuide/latest/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..7e11b9d3a --- /dev/null +++ b/src/UserGuide/latest/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,75 @@ + + +# 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 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 uses`tree `model or`table `model | No | tree | +| `-db` | `--database` | Target database to export (only applies when`-sql_dialect=table`) | Required if`-sql_dialect=table` | - | +| `-table` | `--table` | Target table to export (only applies when`-sql_dialect=table`) | No | - | +| `-t` | `--target` | Output directory (created if it doesn't exist) | Yes | | +| `-path` | `--path_pattern` | Path pattern for metadata export | Required if`-sql_dialect=tree` | | +| `-pfn` | `--prefix_file_name` | Output filename prefix | No | `dump_dbname.sql` | +| `-lpf` | `--lines_per_file` | Maximum lines per dump file (only applies when`-sql_dialect=tree`) | No | `10000` | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (`-1`= no timeout) | No | -1Range:`-1 to Long. max=9223372036854775807` | +| `-help` | `--help` | Display help information | No | | + +### 2.2 Command + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 Examples + + +```Bash +# 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 +``` \ No newline at end of file diff --git a/src/UserGuide/latest/Tools-System/Schema-Import-Tool.md b/src/UserGuide/latest/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..d4a1aa68d --- /dev/null +++ b/src/UserGuide/latest/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,81 @@ + + +# 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 uses`tree `model or`table `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 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 Examples + +```Bash +# 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| ++------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+ +``` diff --git a/src/zh/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md b/src/zh/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..0dc236059 --- /dev/null +++ b/src/zh/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,101 @@ + + +# 元数据导出 + +## 1. 功能概述 + +元数据导出工具 `export-schema.sh/bat` 位于tools 目录下,能够将 IoTDB 中指定数据库下的元数据导出为脚本文件。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | -------------------------- | ------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | 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 运行命令 + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 运行示例 + +将 `database1` 下的元数据导出到`/home`下 + +```Bash +./export-schema.sh -sql_dialect table -t /home/ -db database1 +``` + +导出文件 `dump_database1.sql`,内容格式如下: + +```sql +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` diff --git a/src/zh/UserGuide/Master/Table/Tools-System/Schema-Import-Tool.md b/src/zh/UserGuide/Master/Table/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..3060e5fa6 --- /dev/null +++ b/src/zh/UserGuide/Master/Table/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,157 @@ + + +# 元数据导入 + +## 1. 功能概述 + +元数据导入工具 `import-schema.sh/bat` 位于tools 目录下,能够将指定路径下创建元数据的脚本文件导入到 IoTDB 中。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | ------------------------------- | ----------------------------------------------------------------------------- | -------------- | --------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | root | +| `-sql_dialect` | `--sql_dialect` | 选择 server 是树模型还是表模型,当前支持 tree 和 table 类型 | 否 | tree | +| `-db` | `--database` | 将要导入的目标数据库 | `是` | - | +| `-table` | `--table` | 将要导入的目标表,只在`-sql_dialect`为 table 类型下生效。 | 否 | - | +| `-s` | `--source` | 待加载的脚本文件(夹)的本地目录路径。 | 是 | | +| `-fd` | `--fail_dir` | 指定保存失败文件的目录 | 否 | | +| `-lpf` | `--lines_per_failed_file` | 指定失败文件最大写入数据的行数,只在`-sql_dialect`为 table 类型下生效。 | 否 | 100000范围:0~Integer.Max=2147483647 | +| `-help` | `--help` | 显示帮助信息 | 否 | | + +### 2.2 运行命令 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 运行示例 + + +将 `/home `下的文件 `dump_database1.sql` 导入到 `database2 `中,文件内容如下: + +```sql +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` + +执行脚本: + +```Bash +./import-schema.sh -sql_dialect table -s /home/dump_database1.sql -db database2 + +# database2 不存在时,提示错误信息如下 +The target database database2 does not exist + +# database2 存在时,提示成功 +Import completely! +``` + +验证导入元数据: + +```Bash +# 导入前 +IoTDB:database2> show tables ++---------+-------+ +|TableName|TTL(ms)| ++---------+-------+ ++---------+-------+ +Empty set. + +# 导入后 +IoTDB:database2> show tables details ++---------+-------+------+-------+ +|TableName|TTL(ms)|Status|Comment| ++---------+-------+------+-------+ +| table2| INF| USING| null| +| table1| INF| USING| null| ++---------+-------+------+-------+ + +IoTDB:database2> desc table1 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ + +IoTDB:database2> desc table2 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ +``` diff --git a/src/zh/UserGuide/Master/Tree/Tools-System/Schema-Export-Tool.md b/src/zh/UserGuide/Master/Tree/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..ec217b1e7 --- /dev/null +++ b/src/zh/UserGuide/Master/Tree/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,74 @@ + + +# 元数据导出 + +## 1. 功能概述 + +元数据导出工具 `export-schema.sh/bat` 位于tools 目录下,能够将 IoTDB 中指定数据库下的元数据导出为脚本文件。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | -------------------------- | ------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | 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 运行命令 + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 运行示例 + +```Bash +# 导出 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 +``` diff --git a/src/zh/UserGuide/Master/Tree/Tools-System/Schema-Import-Tool.md b/src/zh/UserGuide/Master/Tree/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..22bd3cc3b --- /dev/null +++ b/src/zh/UserGuide/Master/Tree/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,81 @@ + + +# 元数据导入 + +## 1. 功能概述 + +元数据导入工具 `import-schema.sh/bat` 位于tools 目录下,能够将指定路径下创建元数据的脚本文件导入到 IoTDB 中。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | ------------------------------- | ----------------------------------------------------------------------------- | -------------- | --------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | root | +| `-sql_dialect` | `--sql_dialect` | 选择 server 是树模型还是表模型,当前支持 tree 和 table 类型 | 否 | tree | +| `-db` | `--database` | 将要导入的目标数据库 | `是` | - | +| `-table` | `--table` | 将要导入的目标表,只在`-sql_dialect`为 table 类型下生效。 | 否 | - | +| `-s` | `--source` | 待加载的脚本文件(夹)的本地目录路径。 | 是 | | +| `-fd` | `--fail_dir` | 指定保存失败文件的目录 | 否 | | +| `-lpf` | `--lines_per_failed_file` | 指定失败文件最大写入数据的行数,只在`-sql_dialect`为 table 类型下生效。 | 否 | 100000范围:0~Integer.Max=2147483647 | +| `-help` | `--help` | 显示帮助信息 | 否 | | + +### 2.2 运行命令 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 运行示例 + +```Bash +# 导入前 +IoTDB> show timeseries root.treedb.** ++----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+ +|Timeseries|Alias|Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType| ++----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+ ++----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+ + +# 执行导入命令 +./import-schema.sh -sql_dialect tree -s /home/dump0_0.csv -db root.treedb + +# 导入成功后验证 +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| ++------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+ +``` diff --git a/src/zh/UserGuide/latest-Table/Tools-System/Schema-Export-Tool.md b/src/zh/UserGuide/latest-Table/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..0dc236059 --- /dev/null +++ b/src/zh/UserGuide/latest-Table/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,101 @@ + + +# 元数据导出 + +## 1. 功能概述 + +元数据导出工具 `export-schema.sh/bat` 位于tools 目录下,能够将 IoTDB 中指定数据库下的元数据导出为脚本文件。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | -------------------------- | ------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | 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 运行命令 + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 运行示例 + +将 `database1` 下的元数据导出到`/home`下 + +```Bash +./export-schema.sh -sql_dialect table -t /home/ -db database1 +``` + +导出文件 `dump_database1.sql`,内容格式如下: + +```sql +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` diff --git a/src/zh/UserGuide/latest-Table/Tools-System/Schema-Import-Tool.md b/src/zh/UserGuide/latest-Table/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..3060e5fa6 --- /dev/null +++ b/src/zh/UserGuide/latest-Table/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,157 @@ + + +# 元数据导入 + +## 1. 功能概述 + +元数据导入工具 `import-schema.sh/bat` 位于tools 目录下,能够将指定路径下创建元数据的脚本文件导入到 IoTDB 中。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | ------------------------------- | ----------------------------------------------------------------------------- | -------------- | --------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | root | +| `-sql_dialect` | `--sql_dialect` | 选择 server 是树模型还是表模型,当前支持 tree 和 table 类型 | 否 | tree | +| `-db` | `--database` | 将要导入的目标数据库 | `是` | - | +| `-table` | `--table` | 将要导入的目标表,只在`-sql_dialect`为 table 类型下生效。 | 否 | - | +| `-s` | `--source` | 待加载的脚本文件(夹)的本地目录路径。 | 是 | | +| `-fd` | `--fail_dir` | 指定保存失败文件的目录 | 否 | | +| `-lpf` | `--lines_per_failed_file` | 指定失败文件最大写入数据的行数,只在`-sql_dialect`为 table 类型下生效。 | 否 | 100000范围:0~Integer.Max=2147483647 | +| `-help` | `--help` | 显示帮助信息 | 否 | | + +### 2.2 运行命令 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 运行示例 + + +将 `/home `下的文件 `dump_database1.sql` 导入到 `database2 `中,文件内容如下: + +```sql +DROP TABLE IF EXISTS table1; +CREATE TABLE table1( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +DROP TABLE IF EXISTS table2; +CREATE TABLE table2( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status BOOLEAN FIELD, + arrival_time TIMESTAMP FIELD +); +``` + +执行脚本: + +```Bash +./import-schema.sh -sql_dialect table -s /home/dump_database1.sql -db database2 + +# database2 不存在时,提示错误信息如下 +The target database database2 does not exist + +# database2 存在时,提示成功 +Import completely! +``` + +验证导入元数据: + +```Bash +# 导入前 +IoTDB:database2> show tables ++---------+-------+ +|TableName|TTL(ms)| ++---------+-------+ ++---------+-------+ +Empty set. + +# 导入后 +IoTDB:database2> show tables details ++---------+-------+------+-------+ +|TableName|TTL(ms)|Status|Comment| ++---------+-------+------+-------+ +| table2| INF| USING| null| +| table1| INF| USING| null| ++---------+-------+------+-------+ + +IoTDB:database2> desc table1 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ + +IoTDB:database2> desc table2 ++------------+---------+---------+ +| ColumnName| DataType| Category| ++------------+---------+---------+ +| time|TIMESTAMP| TIME| +| region| STRING| TAG| +| plant_id| STRING| TAG| +| device_id| STRING| TAG| +| model_id| STRING|ATTRIBUTE| +| maintenance| STRING|ATTRIBUTE| +| temperature| FLOAT| FIELD| +| humidity| FLOAT| FIELD| +| status| BOOLEAN| FIELD| +|arrival_time|TIMESTAMP| FIELD| ++------------+---------+---------+ +``` diff --git a/src/zh/UserGuide/latest/Tools-System/Schema-Export-Tool.md b/src/zh/UserGuide/latest/Tools-System/Schema-Export-Tool.md new file mode 100644 index 000000000..ec217b1e7 --- /dev/null +++ b/src/zh/UserGuide/latest/Tools-System/Schema-Export-Tool.md @@ -0,0 +1,74 @@ + + +# 元数据导出 + +## 1. 功能概述 + +元数据导出工具 `export-schema.sh/bat` 位于tools 目录下,能够将 IoTDB 中指定数据库下的元数据导出为脚本文件。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | -------------------------- | ------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | 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 运行命令 + +```Bash +Shell +# Unix/OS X +> tools/export-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +# Windows +> tools\export-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -t [-path ] [-pfn ] + [-lpf ] [-timeout ] +``` + +### 2.3 运行示例 + +```Bash +# 导出 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 +``` diff --git a/src/zh/UserGuide/latest/Tools-System/Schema-Import-Tool.md b/src/zh/UserGuide/latest/Tools-System/Schema-Import-Tool.md new file mode 100644 index 000000000..22bd3cc3b --- /dev/null +++ b/src/zh/UserGuide/latest/Tools-System/Schema-Import-Tool.md @@ -0,0 +1,81 @@ + + +# 元数据导入 + +## 1. 功能概述 + +元数据导入工具 `import-schema.sh/bat` 位于tools 目录下,能够将指定路径下创建元数据的脚本文件导入到 IoTDB 中。 + +## 2. 功能详解 + +### 2.1 参数介绍 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| --------------------- | ------------------------------- | ----------------------------------------------------------------------------- | -------------- | --------------------------------------- | +| `-h` | `-- host` | 主机名 | 否 | 127.0.0.1 | +| `-p` | `--port` | 端口号 | 否 | 6667 | +| `-u` | `--username` | 用户名 | 否 | root | +| `-pw` | `--password` | 密码 | 否 | root | +| `-sql_dialect` | `--sql_dialect` | 选择 server 是树模型还是表模型,当前支持 tree 和 table 类型 | 否 | tree | +| `-db` | `--database` | 将要导入的目标数据库 | `是` | - | +| `-table` | `--table` | 将要导入的目标表,只在`-sql_dialect`为 table 类型下生效。 | 否 | - | +| `-s` | `--source` | 待加载的脚本文件(夹)的本地目录路径。 | 是 | | +| `-fd` | `--fail_dir` | 指定保存失败文件的目录 | 否 | | +| `-lpf` | `--lines_per_failed_file` | 指定失败文件最大写入数据的行数,只在`-sql_dialect`为 table 类型下生效。 | 否 | 100000范围:0~Integer.Max=2147483647 | +| `-help` | `--help` | 显示帮助信息 | 否 | | + +### 2.2 运行命令 + +```Bash +# Unix/OS X +tools/import-schema.sh [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] + +# Windows +tools\import-schema.bat [-sql_dialect] -db -table
+ [-h ] [-p ] [-u ] [-pw ] + -s [-fd ] [-lpf ] +``` + +### 2.3 运行示例 + +```Bash +# 导入前 +IoTDB> show timeseries root.treedb.** ++----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+ +|Timeseries|Alias|Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType| ++----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+ ++----------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+ + +# 执行导入命令 +./import-schema.sh -sql_dialect tree -s /home/dump0_0.csv -db root.treedb + +# 导入成功后验证 +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| ++------------------------------+-----+-----------+--------+--------+-----------+----+----------+--------+------------------+--------+ +```