Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar/V2.0.x/en-Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
],
},
{
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar/V2.0.x/en-Tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar/V2.0.x/zh-Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
],
},
{
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar/V2.0.x/zh-Tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
],
},
{
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
],
},
{
Expand Down
14 changes: 12 additions & 2 deletions src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
Expand Down
101 changes: 101 additions & 0 deletions src/UserGuide/Master/Table/Tools-System/Schema-Export-Tool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->

# 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<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
> 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>]
```

### 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
);
```
Loading