Skip to content

Commit 4236c4e

Browse files
authored
add schema import and export (#718)
1 parent 088f12e commit 4236c4e

24 files changed

Lines changed: 1750 additions & 16 deletions

File tree

src/.vuepress/sidebar/V2.0.x/en-Table.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,18 @@ export const enSidebar = {
120120
{ text: 'Monitor Tool', link: 'Monitor-Tool_apache' },
121121
{ text: 'Benchmark Tool', link: 'Benchmark' },
122122
{ text: 'Cluster Management Tool', link: 'Maintenance-Tool_apache' },
123-
{ text: 'Data Import', link: 'Data-Import-Tool' },
124-
{ text: 'Data Export', link: 'Data-Export-Tool' },
123+
{ text: 'Data Import & Export', collapsible: true,
124+
children: [
125+
{ text: 'Data Import', link: 'Data-Import-Tool' },
126+
{ text: 'Data Export', link: 'Data-Export-Tool' },
127+
],
128+
},
129+
{ text: 'Schema Import & Export', collapsible: true,
130+
children: [
131+
{ text: 'Schema Import', link: 'Schema-Import-Tool' },
132+
{ text: 'Schema Export', link: 'Schema-Export-Tool' },
133+
],
134+
},
125135
],
126136
},
127137
{

src/.vuepress/sidebar/V2.0.x/en-Tree.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,18 @@ export const enSidebar = {
143143
{ text: 'Monitor Tool', link: 'Monitor-Tool_apache' },
144144
{ text: 'Benchmark Tool', link: 'Benchmark' },
145145
{ text: 'Cluster Management Tool', link: 'Maintenance-Tool_apache' },
146-
{ text: 'Data Import', link: 'Data-Import-Tool' },
147-
{ text: 'Data Export', link: 'Data-Export-Tool' },
146+
{ text: 'Data Import & Export', collapsible: true,
147+
children: [
148+
{ text: 'Data Import', link: 'Data-Import-Tool' },
149+
{ text: 'Data Export', link: 'Data-Export-Tool' },
150+
],
151+
},
152+
{ text: 'Schema Import & Export', collapsible: true,
153+
children: [
154+
{ text: 'Schema Import', link: 'Schema-Import-Tool' },
155+
{ text: 'Schema Export', link: 'Schema-Export-Tool' },
156+
],
157+
},
148158
{ text: 'Full Backup Tool', link: 'Backup-Tool' },
149159
{ text: 'Health Check Tool', link: 'Health-Check-Tool' },
150160
],

src/.vuepress/sidebar/V2.0.x/zh-Table.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,18 @@ export const zhSidebar = {
110110
{ text: '命令行工具', link: 'CLI' },
111111
{ text: '监控工具', link: 'Monitor-Tool_apache' },
112112
{ text: '集群管理工具', link: 'Maintenance-Tool_apache' },
113-
{ text: '数据导入', link: 'Data-Import-Tool' },
114-
{ text: '数据导出', link: 'Data-Export-Tool' },
113+
{ text: '数据导入导出', collapsible: true,
114+
children: [
115+
{ text: '数据导入', link: 'Data-Import-Tool' },
116+
{ text: '数据导出', link: 'Data-Export-Tool' },
117+
],
118+
},
119+
{ text: '元数据导入导出', collapsible: true,
120+
children: [
121+
{ text: '元数据导入', link: 'Schema-Import-Tool' },
122+
{ text: '元数据导出', link: 'Schema-Export-Tool' },
123+
],
124+
},
115125
],
116126
},
117127
{

src/.vuepress/sidebar/V2.0.x/zh-Tree.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,18 @@ export const zhSidebar = {
132132
{ text: '监控工具', link: 'Monitor-Tool_apache' },
133133
{ text: '测试工具', link: 'Benchmark' },
134134
{ text: '集群管理工具', link: 'Maintenance-Tool_apache' },
135-
{ text: '数据导入', link: 'Data-Import-Tool' },
136-
{ text: '数据导出', link: 'Data-Export-Tool' },
135+
{ text: '数据导入导出', collapsible: true,
136+
children: [
137+
{ text: '数据导入', link: 'Data-Import-Tool' },
138+
{ text: '数据导出', link: 'Data-Export-Tool' },
139+
],
140+
},
141+
{ text: '元数据导入导出', collapsible: true,
142+
children: [
143+
{ text: '元数据导入', link: 'Schema-Import-Tool' },
144+
{ text: '元数据导出', link: 'Schema-Export-Tool' },
145+
],
146+
},
137147
{ text: '全量备份工具', link: 'Backup-Tool' },
138148
{ text: '健康检查工具', link: 'Health-Check-Tool' },
139149
],

src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,18 @@ export const enSidebar = {
125125
{ text: 'Monitor Tool', link: 'Monitor-Tool_timecho' },
126126
{ text: 'Benchmark Tool', link: 'Benchmark' },
127127
{ text: 'Cluster Management Tool', link: 'Maintenance-Tool_timecho' },
128-
{ text: 'Data Import', link: 'Data-Import-Tool' },
129-
{ text: 'Data Export', link: 'Data-Export-Tool' },
128+
{ text: 'Data Import & Export', collapsible: true,
129+
children: [
130+
{ text: 'Data Import', link: 'Data-Import-Tool' },
131+
{ text: 'Data Export', link: 'Data-Export-Tool' },
132+
],
133+
},
134+
{ text: 'Schema Import & Export', collapsible: true,
135+
children: [
136+
{ text: 'Schema Import', link: 'Schema-Import-Tool' },
137+
{ text: 'Schema Export', link: 'Schema-Export-Tool' },
138+
],
139+
},
130140
],
131141
},
132142
{

src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,18 @@ export const enSidebar = {
159159
{ text: 'Monitor Tool', link: 'Monitor-Tool_timecho' },
160160
{ text: 'Benchmark Tool', link: 'Benchmark' },
161161
{ text: 'Cluster Management Tool', link: 'Maintenance-Tool_timecho' },
162-
{ text: 'Data Import', link: 'Data-Import-Tool' },
163-
{ text: 'Data Export', link: 'Data-Export-Tool' },
162+
{ text: 'Data Import & Export', collapsible: true,
163+
children: [
164+
{ text: 'Data Import', link: 'Data-Import-Tool' },
165+
{ text: 'Data Export', link: 'Data-Export-Tool' },
166+
],
167+
},
168+
{ text: 'Schema Import & Export', collapsible: true,
169+
children: [
170+
{ text: 'Schema Import', link: 'Schema-Import-Tool' },
171+
{ text: 'Schema Export', link: 'Schema-Export-Tool' },
172+
],
173+
},
164174
{ text: 'Full Backup Tool', link: 'Backup-Tool' },
165175
{ text: 'Health Check Tool', link: 'Health-Check-Tool' },
166176
],

src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,18 @@ export const zhSidebar = {
114114
{ text: '监控工具', link: 'Monitor-Tool_timecho' },
115115
{ text: '测试工具', link: 'Benchmark' },
116116
{ text: '集群管理工具', link: 'Maintenance-Tool_timecho' },
117-
{ text: '数据导入', link: 'Data-Import-Tool' },
118-
{ text: '数据导出', link: 'Data-Export-Tool' },
117+
{ text: '数据导入导出', collapsible: true,
118+
children: [
119+
{ text: '数据导入', link: 'Data-Import-Tool' },
120+
{ text: '数据导出', link: 'Data-Export-Tool' },
121+
],
122+
},
123+
{ text: '元数据导入导出', collapsible: true,
124+
children: [
125+
{ text: '元数据导入', link: 'Schema-Import-Tool' },
126+
{ text: '元数据导出', link: 'Schema-Export-Tool' },
127+
],
128+
},
119129
],
120130
},
121131
{

src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,18 @@ export const zhSidebar = {
142142
{ text: '监控工具', link: 'Monitor-Tool_timecho' },
143143
{ text: '测试工具', link: 'Benchmark' },
144144
{ text: '集群管理工具', link: 'Maintenance-Tool_timecho' },
145-
{ text: '数据导入', link: 'Data-Import-Tool' },
146-
{ text: '数据导出', link: 'Data-Export-Tool' },
145+
{ text: '数据导入导出', collapsible: true,
146+
children: [
147+
{ text: '数据导入', link: 'Data-Import-Tool' },
148+
{ text: '数据导出', link: 'Data-Export-Tool' },
149+
],
150+
},
151+
{ text: '元数据导入导出', collapsible: true,
152+
children: [
153+
{ text: '元数据导入', link: 'Schema-Import-Tool' },
154+
{ text: '元数据导出', link: 'Schema-Export-Tool' },
155+
],
156+
},
147157
{ text: '全量备份工具', link: 'Backup-Tool' },
148158
{ text: '健康检查工具', link: 'Health-Check-Tool' },
149159
],
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# Schema Export
23+
24+
## 1. Overview
25+
26+
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.
27+
28+
## 2. Detailed Functionality
29+
30+
### 2.1 Parameter
31+
32+
| **Short Param** | **Full Param** | **Description** | Required | Default |
33+
| ----------------------- | -------------------------- | ------------------------------------------------------------------------ | ------------------------------------- | -------------------------------------------------------- |
34+
| `-h` | `-- host` | Hostname | No | 127.0.0.1 |
35+
| `-p` | `--port` | Port number | No | 6667 |
36+
| `-u` | `--username` | Username | No | root |
37+
| `-pw` | `--password` | Password | No | root |
38+
| `-sql_dialect` | `--sql_dialect` | Specifies whether the server uses`tree `model or`table `model | No | tree |
39+
| `-db` | `--database` | Target database to export (only applies when`-sql_dialect=table`) | Required if`-sql_dialect=table` | - |
40+
| `-table` | `--table` | Target table to export (only applies when`-sql_dialect=table`) | No | - |
41+
| `-t` | `--target` | Output directory (created if it doesn't exist) | Yes | |
42+
| `-path` | `--path_pattern` | Path pattern for metadata export | Required if`-sql_dialect=tree` | |
43+
| `-pfn` | `--prefix_file_name` | Output filename prefix | No | `dump_dbname.sql` |
44+
| `-lpf` | `--lines_per_file` | Maximum lines per dump file (only applies when`-sql_dialect=tree`) | No | `10000` |
45+
| `-timeout` | `--query_timeout` | Query timeout in milliseconds (`-1`= no timeout) | No | -1Range:`-1 to Long. max=9223372036854775807` |
46+
| `-help` | `--help` | Display help information | No | |
47+
48+
### 2.2 Command
49+
50+
```Bash
51+
Shell
52+
# Unix/OS X
53+
> tools/export-schema.sh [-sql_dialect<sql_dialect>] -db<database> -table<table>
54+
[-h <host>] [-p <port>] [-u <username>] [-pw <password>]
55+
-t <target_directory> [-path <exportPathPattern>] [-pfn <prefix_file_name>]
56+
[-lpf <lines_per_file>] [-timeout <query_timeout>]
57+
# Windows
58+
> tools\export-schema.bat [-sql_dialect<sql_dialect>] -db<database> -table<table>
59+
[-h <host>] [-p <port>] [-u <username>] [-pw <password>]
60+
-t <target_directory> [-path <exportPathPattern>] [-pfn <prefix_file_name>]
61+
[-lpf <lines_per_file>] [-timeout <query_timeout>]
62+
```
63+
64+
### 2.3 Examples
65+
66+
Export schema from `database1` to `/home`:
67+
68+
```Bash
69+
./export-schema.sh -sql_dialect table -t /home/ -db database1
70+
```
71+
72+
Output `dump_database1.sql`
73+
74+
```sql
75+
DROP TABLE IF EXISTS table1;
76+
CREATE TABLE table1(
77+
time TIMESTAMP TIME,
78+
region STRING TAG,
79+
plant_id STRING TAG,
80+
device_id STRING TAG,
81+
model_id STRING ATTRIBUTE,
82+
maintenance STRING ATTRIBUTE,
83+
temperature FLOAT FIELD,
84+
humidity FLOAT FIELD,
85+
status BOOLEAN FIELD,
86+
arrival_time TIMESTAMP FIELD
87+
);
88+
DROP TABLE IF EXISTS table2;
89+
CREATE TABLE table2(
90+
time TIMESTAMP TIME,
91+
region STRING TAG,
92+
plant_id STRING TAG,
93+
device_id STRING TAG,
94+
model_id STRING ATTRIBUTE,
95+
maintenance STRING ATTRIBUTE,
96+
temperature FLOAT FIELD,
97+
humidity FLOAT FIELD,
98+
status BOOLEAN FIELD,
99+
arrival_time TIMESTAMP FIELD
100+
);
101+
```

0 commit comments

Comments
 (0)