diff --git a/src/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md b/src/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md index 3c4a60b04..e03376793 100644 --- a/src/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md +++ b/src/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md @@ -1,213 +1,140 @@ # Data Export -## 1. Introduction to Export Tools - -Export tools can export data queried from SQL into specified formats, including the `export-tsfile.sh/bat` script for exporting TsFile files and the `export-data.sh/bat` script that supports exporting in CSV and SQL formats. - -## 2. Supported Data Types - -- CSV: A plain text format for storing formatted data, which needs to be constructed according to the specified CSV format mentioned below. - -- SQL: A file containing custom SQL statements. - -- TsFile: The file format for time series used in IoTDB. - -## 3. export-tsfile Script - -Supports TsFile: The file format for time series used in IoTDB. - - -#### 3.1 Command - -```Bash +## 1. Overview +The data export tool, export-data.sh (Unix/OS X) or export-data.bat (Windows), located in the tools directory, allows users to export query results from specified SQL statements into CSV, SQL, or TsFile (open-source time-series file format) formats. The specific functionalities are as follows: + + + + + + + + + + + + + + + + + + + + + +
File FormatIoTDB ToolDescription
CSVexport-data.sh/batPlain text format for storing structured data. Must follow the CSV format specified below.
SQLFile containing custom SQL statements.
TsFileOpen-source time-series file format.
+ + +## 2. Detailed Functionality +### 2.1 Common Parameters +| Short | Full Parameter | Description | Required | Default | +| ---------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------- |-----------------------------------------------| +| `-ft` | `--file_type` | Export file type: `csv`, `sql`, `tsfile`. | ​**Yes** | - | +| `-h` | `--host` | Hostname of the IoTDB server. | No | `127.0.0.1` | +| `-p` | `--port` | Port number of the IoTDB server. | No | `6667` | +| `-u` | `--username` | Username for authentication. | No | `root` | +| `-pw` | `--password` | Password for authentication. | No | `root` | +| `-t` | `--target` | Target directory for the output files. If the path does not exist, it will be created. | ​**Yes** | - | +| `-pfn` | `--prefix_file_name` | Prefix for the exported file names. For example, `abc` will generate files like `abc_0.tsfile`, `abc_1.tsfile`. | No | `dump_0.tsfile` | +| `-q` | `--query` | SQL query command to execute. | No | - | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (ms). | No | `-1` (Range: -1~Long max=9223372036854775807) | +| `-help` | `--help` | Display help information. | No | - | + +### 2.2 CSV Format +#### 2.2.1 Command + +```Shell # Unix/OS X -tools/export-tsfile.sh -h -p -u -pw -td [-f -q -s ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] # Windows -tools\export-tsfile.bat -h -p -u -pw -td [-f -q -s ] +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] ``` - -#### 3.2 Parameter Introduction - -| **Parameter** | **Definition** | **Required** | **Default** | -| -------- | ------------------------------------------------------------ | ------------ | --------- | -| -h | Hostname | No | 127.0.0.1 | -| -p | Port | No | 6667 | -| -u | Username | No | root | -| -pw | Password | No | root | -| -t | Target file directory, used to specify the directory where the output file should be saved | Yes | - | -| -tfn | Name of the export file | No | - | -| -q | Number of query commands to be executed, possibly used for batch execution of queries | No | - | -| -s | SQL file path, used to specify the location of the file containing the SQL statements to be executed | No | - | -| -timeout | Session query timeout, used to specify the maximum allowed time before the query operation is automatically terminated | No | - | - -In addition, if the `-s` and `-q` parameters are not used, after the export script is started, you need to enter the query statement according to the program prompt, and different query results will be saved to different TsFile files. - - - -#### 3.3 Running Examples - -```Bash -# Unix/OS X -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 - -# Windows -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 +#### 2.2.2 CSV-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ------------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |------------------------------------------| +| `-dt` | `--datatype` | Whether to include data types in the CSV file header (`true` or `false`). | No | `false` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.2.3 Examples + +```Shell +# Valid Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` - -## 4. export-data Script - -Supports CSV: A plain text format for storing formatted data, which needs to be constructed according to the specified CSV format below. - -Supports SQL: A file containing custom SQL statements. - -#### 4.1 Command - -```Bash +## 2.3 SQL Format +#### 2.3.1 Command +```Shell # Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + # Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] ``` - -#### 4.2 Parameter Introduction - -| **Parameter** | **Definition** | **Required** | **Default** | -| --------- | ------------------------------------------------------------ | ------------ | ------------------------ | -| -h | Hostname | No | 127.0.0.1 | -| -p | Port | No | 6667 | -| -u | Username | No | root | -| -pw | Password | No | root | -| -t | Exported CSV or SQL file output path (In V1.3.2, the parameter was `-td`) | Yes | | -| -datatype | Whether to print the corresponding data type behind the time series in the CSV file header, options are true or false | No | true | -| -q | Directly specify the query statement to be executed in the command (currently only supports some statements, detailed list see below) Note: -q and -s parameters are required to fill in one, if filled in at the same time, -q takes effect. For detailed supported SQL statement examples, please refer to "SQL Statement Support Details" below | 否 | | -| -s | Specify the SQL file, which may contain one or more SQL statements. If it contains multiple SQL statements, they should be separated by newlines (carriage returns). Each SQL statement corresponds to one or more output CSV or SQL files. Note: -q and -s parameters are required to fill in one, if filled in at the same time, -q takes effect. For detailed supported SQL statement examples, please refer to "SQL Statement Support Rules" below | 否 | | -| -type | Specify the type of exported file, options are csv or sql | No | csv | -| -tf | Specify the time format. The time format must comply with the[ISO 8601](https://calendars.wikia.org/wiki/ISO_8601)standard, or `timestamp` Explanation: Only effective when the - type is CSV | 否 | yyyy-MM-dd HH:mm:ss.SSSz | -| -lpf | Specify the maximum number of lines in the dump file to be exported (V1.3.2 version parameter is`-linesPerFile`) | No | 10000 | -| -timeout | Specify the timeout period for session queries, in ms | No | -1 | - -#### 4.3 SQL 语句支持规则 - -1. Only query statements are supported; non-query statements (such as metadata management, system management, etc.) are not supported. For unsupported SQL, the program will automatically skip and output an error message. - -2. In query statements, the current version only supports the export of raw data. If there are group by, aggregate functions, UDFs, operational operators, etc., they are not supported for export as SQL. When exporting raw data, please note that if exporting data from multiple devices, please use the align by device statement. Detailed examples are as follows: - - -| | **支持导出** | **示例** | -| ----------------------------------------- | ------------ | --------------------------------------------- | -| Raw data single device query | Supported | select * from root.s_0.d_0 | -| | 原始数据多设备查询(aligin by device) | Supported | select * from root.** align by device | - | 支持 | select * from root.** align by device | -| Raw data multi-device query (without align by device) | Not Supported | select * from root.**select * from root.s_0.* | - -#### 4.4 Running Examples - -- Export all data within the scope of a SQL execution to a CSV file. - -```Bash -# Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - -# Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] -``` - -- Export results - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 -``` - -- Export all data within the scope of all SQL executions in a SQL file to a CSV file. - - -```Bash -# Unix/OS X ->tools/export-data.sh -t ./data/ -s export.sql -# Windows ->tools/export-data.bat -t ./data/ -s export.sql -``` - -- Content of export.sql file (file pointed to by -s parameter) - - -```Bash -select * from root.stock.** limit 100 -select * from root.db.** limit 100 -``` - -- Export result file 1 - - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 -``` - -- Export result file 2 - - -```Bash -Time,root.db.Random.RandomBoolean -2024-07-22T17:16:05.820+08:00,true -2024-07-22T17:16:02.597+08:00,false +#### 2.3.2 SQL-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ---------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | +| `-aligned` | `--use_aligned` | Whether to export as aligned SQL format (`true` or `false`). | No | `true` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.3.3 Examples +```Shell +# Valid Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` -- Export data defined in the SQL file within the IoTDB database in an aligned format as SQL statements. +### 2.4 TsFile Format +#### 2.4.1 Command -```Bash +```Shell # Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + # Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] ``` -- Export results +#### 2.4.2 TsFile-Specific Parameters +* None -```Bash -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249629831,0.62308747,2.0,0.012206747854849653,-6.0,false,0.14164352); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249630834,0.7520042,3.0,0.22760657101910464,-5.0,true,0.089064896); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249631835,0.3981064,3.0,0.6254559288663467,-6.0,false,0.9767922); -``` - -- Export all data within the scope of a SQL execution to a CSV file, specifying the export time format as `yyyy-MM-dd HH:mm:ss`, and print the corresponding data type behind the table header time series. +#### 2.4.3 Examples - -```Bash -# Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -# Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true +```Shell +# Valid Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# Error Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` - -- Export results - - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice(DOUBLE),root.stock.Legacy.0700HK.Type(DOUBLE),root.stock.Legacy.0700HK.L1_BidSize(DOUBLE),root.stock.Legacy.0700HK.Domain(DOUBLE),root.stock.Legacy.0700HK.L1_BuyNo(BOOLEAN),root.stock.Legacy.0700HK.L1_AskPrice(DOUBLE) -2024-07-30 10:33:55,0.44574088,3.0,0.21476832811611501,-4.0,true,0.5951748 -2024-07-30 10:33:56,0.6880933,3.0,0.6289119476165305,-5.0,false,0.114634395 -``` \ No newline at end of file diff --git a/src/UserGuide/V1.3.x/Tools-System/Data-Export-Tool-1-3-4.md b/src/UserGuide/V1.3.x/Tools-System/Data-Export-Tool-1-3-4.md new file mode 100644 index 000000000..e03376793 --- /dev/null +++ b/src/UserGuide/V1.3.x/Tools-System/Data-Export-Tool-1-3-4.md @@ -0,0 +1,140 @@ +# Data Export + +## 1. Overview +The data export tool, export-data.sh (Unix/OS X) or export-data.bat (Windows), located in the tools directory, allows users to export query results from specified SQL statements into CSV, SQL, or TsFile (open-source time-series file format) formats. The specific functionalities are as follows: + + + + + + + + + + + + + + + + + + + + + +
File FormatIoTDB ToolDescription
CSVexport-data.sh/batPlain text format for storing structured data. Must follow the CSV format specified below.
SQLFile containing custom SQL statements.
TsFileOpen-source time-series file format.
+ + +## 2. Detailed Functionality +### 2.1 Common Parameters +| Short | Full Parameter | Description | Required | Default | +| ---------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------- |-----------------------------------------------| +| `-ft` | `--file_type` | Export file type: `csv`, `sql`, `tsfile`. | ​**Yes** | - | +| `-h` | `--host` | Hostname of the IoTDB server. | No | `127.0.0.1` | +| `-p` | `--port` | Port number of the IoTDB server. | No | `6667` | +| `-u` | `--username` | Username for authentication. | No | `root` | +| `-pw` | `--password` | Password for authentication. | No | `root` | +| `-t` | `--target` | Target directory for the output files. If the path does not exist, it will be created. | ​**Yes** | - | +| `-pfn` | `--prefix_file_name` | Prefix for the exported file names. For example, `abc` will generate files like `abc_0.tsfile`, `abc_1.tsfile`. | No | `dump_0.tsfile` | +| `-q` | `--query` | SQL query command to execute. | No | - | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (ms). | No | `-1` (Range: -1~Long max=9223372036854775807) | +| `-help` | `--help` | Display help information. | No | - | + +### 2.2 CSV Format +#### 2.2.1 Command + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +# Windows +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +``` +#### 2.2.2 CSV-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ------------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |------------------------------------------| +| `-dt` | `--datatype` | Whether to include data types in the CSV file header (`true` or `false`). | No | `false` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.2.3 Examples + +```Shell +# Valid Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` +## 2.3 SQL Format +#### 2.3.1 Command +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + +# Windows +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] +``` +#### 2.3.2 SQL-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ---------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | +| `-aligned` | `--use_aligned` | Whether to export as aligned SQL format (`true` or `false`). | No | `true` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.3.3 Examples +```Shell +# Valid Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` + +### 2.4 TsFile Format + +#### 2.4.1 Command + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + +# Windows +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] +``` + +#### 2.4.2 TsFile-Specific Parameters + +* None + +#### 2.4.3 Examples + +```Shell +# Valid Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# Error Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` diff --git a/src/UserGuide/dev-1.3/Tools-System/Data-Export-Tool-1-3-4.md b/src/UserGuide/dev-1.3/Tools-System/Data-Export-Tool-1-3-4.md new file mode 100644 index 000000000..e03376793 --- /dev/null +++ b/src/UserGuide/dev-1.3/Tools-System/Data-Export-Tool-1-3-4.md @@ -0,0 +1,140 @@ +# Data Export + +## 1. Overview +The data export tool, export-data.sh (Unix/OS X) or export-data.bat (Windows), located in the tools directory, allows users to export query results from specified SQL statements into CSV, SQL, or TsFile (open-source time-series file format) formats. The specific functionalities are as follows: + + + + + + + + + + + + + + + + + + + + + +
File FormatIoTDB ToolDescription
CSVexport-data.sh/batPlain text format for storing structured data. Must follow the CSV format specified below.
SQLFile containing custom SQL statements.
TsFileOpen-source time-series file format.
+ + +## 2. Detailed Functionality +### 2.1 Common Parameters +| Short | Full Parameter | Description | Required | Default | +| ---------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------- |-----------------------------------------------| +| `-ft` | `--file_type` | Export file type: `csv`, `sql`, `tsfile`. | ​**Yes** | - | +| `-h` | `--host` | Hostname of the IoTDB server. | No | `127.0.0.1` | +| `-p` | `--port` | Port number of the IoTDB server. | No | `6667` | +| `-u` | `--username` | Username for authentication. | No | `root` | +| `-pw` | `--password` | Password for authentication. | No | `root` | +| `-t` | `--target` | Target directory for the output files. If the path does not exist, it will be created. | ​**Yes** | - | +| `-pfn` | `--prefix_file_name` | Prefix for the exported file names. For example, `abc` will generate files like `abc_0.tsfile`, `abc_1.tsfile`. | No | `dump_0.tsfile` | +| `-q` | `--query` | SQL query command to execute. | No | - | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (ms). | No | `-1` (Range: -1~Long max=9223372036854775807) | +| `-help` | `--help` | Display help information. | No | - | + +### 2.2 CSV Format +#### 2.2.1 Command + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +# Windows +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +``` +#### 2.2.2 CSV-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ------------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |------------------------------------------| +| `-dt` | `--datatype` | Whether to include data types in the CSV file header (`true` or `false`). | No | `false` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.2.3 Examples + +```Shell +# Valid Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` +## 2.3 SQL Format +#### 2.3.1 Command +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + +# Windows +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] +``` +#### 2.3.2 SQL-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ---------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | +| `-aligned` | `--use_aligned` | Whether to export as aligned SQL format (`true` or `false`). | No | `true` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.3.3 Examples +```Shell +# Valid Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` + +### 2.4 TsFile Format + +#### 2.4.1 Command + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + +# Windows +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] +``` + +#### 2.4.2 TsFile-Specific Parameters + +* None + +#### 2.4.3 Examples + +```Shell +# Valid Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# Error Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` diff --git a/src/UserGuide/latest/Tools-System/Data-Export-Tool.md b/src/UserGuide/latest/Tools-System/Data-Export-Tool.md index 3c4a60b04..e03376793 100644 --- a/src/UserGuide/latest/Tools-System/Data-Export-Tool.md +++ b/src/UserGuide/latest/Tools-System/Data-Export-Tool.md @@ -1,213 +1,140 @@ # Data Export -## 1. Introduction to Export Tools - -Export tools can export data queried from SQL into specified formats, including the `export-tsfile.sh/bat` script for exporting TsFile files and the `export-data.sh/bat` script that supports exporting in CSV and SQL formats. - -## 2. Supported Data Types - -- CSV: A plain text format for storing formatted data, which needs to be constructed according to the specified CSV format mentioned below. - -- SQL: A file containing custom SQL statements. - -- TsFile: The file format for time series used in IoTDB. - -## 3. export-tsfile Script - -Supports TsFile: The file format for time series used in IoTDB. - - -#### 3.1 Command - -```Bash +## 1. Overview +The data export tool, export-data.sh (Unix/OS X) or export-data.bat (Windows), located in the tools directory, allows users to export query results from specified SQL statements into CSV, SQL, or TsFile (open-source time-series file format) formats. The specific functionalities are as follows: + + + + + + + + + + + + + + + + + + + + + +
File FormatIoTDB ToolDescription
CSVexport-data.sh/batPlain text format for storing structured data. Must follow the CSV format specified below.
SQLFile containing custom SQL statements.
TsFileOpen-source time-series file format.
+ + +## 2. Detailed Functionality +### 2.1 Common Parameters +| Short | Full Parameter | Description | Required | Default | +| ---------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------- |-----------------------------------------------| +| `-ft` | `--file_type` | Export file type: `csv`, `sql`, `tsfile`. | ​**Yes** | - | +| `-h` | `--host` | Hostname of the IoTDB server. | No | `127.0.0.1` | +| `-p` | `--port` | Port number of the IoTDB server. | No | `6667` | +| `-u` | `--username` | Username for authentication. | No | `root` | +| `-pw` | `--password` | Password for authentication. | No | `root` | +| `-t` | `--target` | Target directory for the output files. If the path does not exist, it will be created. | ​**Yes** | - | +| `-pfn` | `--prefix_file_name` | Prefix for the exported file names. For example, `abc` will generate files like `abc_0.tsfile`, `abc_1.tsfile`. | No | `dump_0.tsfile` | +| `-q` | `--query` | SQL query command to execute. | No | - | +| `-timeout` | `--query_timeout` | Query timeout in milliseconds (ms). | No | `-1` (Range: -1~Long max=9223372036854775807) | +| `-help` | `--help` | Display help information. | No | - | + +### 2.2 CSV Format +#### 2.2.1 Command + +```Shell # Unix/OS X -tools/export-tsfile.sh -h -p -u -pw -td [-f -q -s ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] # Windows -tools\export-tsfile.bat -h -p -u -pw -td [-f -q -s ] +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] ``` - -#### 3.2 Parameter Introduction - -| **Parameter** | **Definition** | **Required** | **Default** | -| -------- | ------------------------------------------------------------ | ------------ | --------- | -| -h | Hostname | No | 127.0.0.1 | -| -p | Port | No | 6667 | -| -u | Username | No | root | -| -pw | Password | No | root | -| -t | Target file directory, used to specify the directory where the output file should be saved | Yes | - | -| -tfn | Name of the export file | No | - | -| -q | Number of query commands to be executed, possibly used for batch execution of queries | No | - | -| -s | SQL file path, used to specify the location of the file containing the SQL statements to be executed | No | - | -| -timeout | Session query timeout, used to specify the maximum allowed time before the query operation is automatically terminated | No | - | - -In addition, if the `-s` and `-q` parameters are not used, after the export script is started, you need to enter the query statement according to the program prompt, and different query results will be saved to different TsFile files. - - - -#### 3.3 Running Examples - -```Bash -# Unix/OS X -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 - -# Windows -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 +#### 2.2.2 CSV-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ------------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |------------------------------------------| +| `-dt` | `--datatype` | Whether to include data types in the CSV file header (`true` or `false`). | No | `false` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.2.3 Examples + +```Shell +# Valid Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` - -## 4. export-data Script - -Supports CSV: A plain text format for storing formatted data, which needs to be constructed according to the specified CSV format below. - -Supports SQL: A file containing custom SQL statements. - -#### 4.1 Command - -```Bash +## 2.3 SQL Format +#### 2.3.1 Command +```Shell # Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + # Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] ``` - -#### 4.2 Parameter Introduction - -| **Parameter** | **Definition** | **Required** | **Default** | -| --------- | ------------------------------------------------------------ | ------------ | ------------------------ | -| -h | Hostname | No | 127.0.0.1 | -| -p | Port | No | 6667 | -| -u | Username | No | root | -| -pw | Password | No | root | -| -t | Exported CSV or SQL file output path (In V1.3.2, the parameter was `-td`) | Yes | | -| -datatype | Whether to print the corresponding data type behind the time series in the CSV file header, options are true or false | No | true | -| -q | Directly specify the query statement to be executed in the command (currently only supports some statements, detailed list see below) Note: -q and -s parameters are required to fill in one, if filled in at the same time, -q takes effect. For detailed supported SQL statement examples, please refer to "SQL Statement Support Details" below | 否 | | -| -s | Specify the SQL file, which may contain one or more SQL statements. If it contains multiple SQL statements, they should be separated by newlines (carriage returns). Each SQL statement corresponds to one or more output CSV or SQL files. Note: -q and -s parameters are required to fill in one, if filled in at the same time, -q takes effect. For detailed supported SQL statement examples, please refer to "SQL Statement Support Rules" below | 否 | | -| -type | Specify the type of exported file, options are csv or sql | No | csv | -| -tf | Specify the time format. The time format must comply with the[ISO 8601](https://calendars.wikia.org/wiki/ISO_8601)standard, or `timestamp` Explanation: Only effective when the - type is CSV | 否 | yyyy-MM-dd HH:mm:ss.SSSz | -| -lpf | Specify the maximum number of lines in the dump file to be exported (V1.3.2 version parameter is`-linesPerFile`) | No | 10000 | -| -timeout | Specify the timeout period for session queries, in ms | No | -1 | - -#### 4.3 SQL 语句支持规则 - -1. Only query statements are supported; non-query statements (such as metadata management, system management, etc.) are not supported. For unsupported SQL, the program will automatically skip and output an error message. - -2. In query statements, the current version only supports the export of raw data. If there are group by, aggregate functions, UDFs, operational operators, etc., they are not supported for export as SQL. When exporting raw data, please note that if exporting data from multiple devices, please use the align by device statement. Detailed examples are as follows: - - -| | **支持导出** | **示例** | -| ----------------------------------------- | ------------ | --------------------------------------------- | -| Raw data single device query | Supported | select * from root.s_0.d_0 | -| | 原始数据多设备查询(aligin by device) | Supported | select * from root.** align by device | - | 支持 | select * from root.** align by device | -| Raw data multi-device query (without align by device) | Not Supported | select * from root.**select * from root.s_0.* | - -#### 4.4 Running Examples - -- Export all data within the scope of a SQL execution to a CSV file. - -```Bash -# Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - -# Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] -``` - -- Export results - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 -``` - -- Export all data within the scope of all SQL executions in a SQL file to a CSV file. - - -```Bash -# Unix/OS X ->tools/export-data.sh -t ./data/ -s export.sql -# Windows ->tools/export-data.bat -t ./data/ -s export.sql -``` - -- Content of export.sql file (file pointed to by -s parameter) - - -```Bash -select * from root.stock.** limit 100 -select * from root.db.** limit 100 -``` - -- Export result file 1 - - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 -``` - -- Export result file 2 - - -```Bash -Time,root.db.Random.RandomBoolean -2024-07-22T17:16:05.820+08:00,true -2024-07-22T17:16:02.597+08:00,false +#### 2.3.2 SQL-Specific Parameters + +| Short | Full Parameter | Description | Required | Default | +| ---------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | +| `-aligned` | `--use_aligned` | Whether to export as aligned SQL format (`true` or `false`). | No | `true` | +| `-lpf` | `--lines_per_file` | Number of rows per exported file. | No | `10000` (Range:0~Integer.Max=2147483647) | +| `-tf` | `--time_format` | Time format for the CSV file. Options: 1) Timestamp (numeric, long), 2) ISO8601 (default), 3) Custom pattern (e.g., `yyyy-MM-dd HH:mm:ss`). SQL file timestamps are unaffected by this setting. | No | `ISO8601` | +| `-tz` | `--timezone` | Timezone setting (e.g., `+08:00`, `-01:00`). | No | System default | + +#### 2.3.3 Examples +```Shell +# Valid Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# Error Example +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` -- Export data defined in the SQL file within the IoTDB database in an aligned format as SQL statements. +### 2.4 TsFile Format +#### 2.4.1 Command -```Bash +```Shell # Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + # Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] ``` -- Export results +#### 2.4.2 TsFile-Specific Parameters +* None -```Bash -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249629831,0.62308747,2.0,0.012206747854849653,-6.0,false,0.14164352); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249630834,0.7520042,3.0,0.22760657101910464,-5.0,true,0.089064896); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249631835,0.3981064,3.0,0.6254559288663467,-6.0,false,0.9767922); -``` - -- Export all data within the scope of a SQL execution to a CSV file, specifying the export time format as `yyyy-MM-dd HH:mm:ss`, and print the corresponding data type behind the table header time series. +#### 2.4.3 Examples - -```Bash -# Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -# Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true +```Shell +# Valid Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# Error Example +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` - -- Export results - - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice(DOUBLE),root.stock.Legacy.0700HK.Type(DOUBLE),root.stock.Legacy.0700HK.L1_BidSize(DOUBLE),root.stock.Legacy.0700HK.Domain(DOUBLE),root.stock.Legacy.0700HK.L1_BuyNo(BOOLEAN),root.stock.Legacy.0700HK.L1_AskPrice(DOUBLE) -2024-07-30 10:33:55,0.44574088,3.0,0.21476832811611501,-4.0,true,0.5951748 -2024-07-30 10:33:56,0.6880933,3.0,0.6289119476165305,-5.0,false,0.114634395 -``` \ No newline at end of file diff --git a/src/zh/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md b/src/zh/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md index 361d5076e..e4d1fc09b 100644 --- a/src/zh/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md +++ b/src/zh/UserGuide/Master/Tree/Tools-System/Data-Export-Tool.md @@ -1,199 +1,150 @@ # 数据导出 -## 1. 导出工具介绍 - -导出工具可以将 SQL 查询的数据导出为指定的格式,包含用于导出 TsFile 文件的 `export-tsfile.sh/bat` 脚本和支持 CSV 和 SQL 格式的导出的 `export-data.sh/bat` 脚本。 - -## 2. 支持的数据类型 - -- CSV:纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造 - -- SQL:包含自定义 SQL 语句的文件 - -- TsFile: IoTDB 中使用的时间序列的文件格式 - -## 3. export-tsfile 脚本 - -支持 TsFile: IoTDB 中使用的时间序列的文件格式 - -#### 3.1 运行命令 - -```Bash +## 1. 功能概述 + +数据导出工具 export-data.sh/bat 位于 tools 目录下,能够将指定 SQL 的查询结果导出为 CSV、SQL 及 TsFile(开源时间序列文件格式)格式。具体功能如下: + + + + + + + + + + + + + + + + + + + + + +
文件格式IoTDB工具具体介绍
CSVexport-data.sh/bat纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造
SQL包含自定义 SQL 语句的文件
TsFile开源时序数据文件格式
+ + +## 2. 功能详解 + +### 2.1 公共参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | ---------------------- | ---------------------------------------------------------------------- | -------------- | ------------------------------------------ | +| -ft | --file\_type | 导出文件的类型,可以选择:csv、sql、tsfile | √ | | +| -h | -- host | 主机名 | 否 | 127.0.0.1 | +| -p | --port | 端口号 | 否 | 6667 | +| -u | --username | 用户名 | 否 | root | +| -pw | --password | 密码 | 否 | root | +| -t | --target | 指定输出文件的目标文件夹,如果路径不存在新建文件夹 | √ | | +| -pfn | --prefix\_file\_name | 指定导出文件的名称。例如:abc,生成的文件是abc\_0.tsfile、abc\_1.tsfile | 否 | dump\_0.tsfile | +| -q | --query | 要执行的查询命令 | 否 | 无 | +| -timeout | --query\_timeout | 会话查询的超时时间(ms) | 否 | -1
范围:-1~Long max=9223372036854775807 | +| -help | --help | 显示帮助信息 | 否 | | + +### 2.2 Csv 格式 + +#### 2.2.1 运行命令 + +```Shell # Unix/OS X -tools/export-tsfile.sh -h -p -u -pw -td [-f -q -s ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] # Windows -tools\export-tsfile.bat -h -p -u -pw -td [-f -q -s ] +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] ``` -#### 3.2 参数介绍 - -| **参数** | **定义** | **是否必填** | **默认** | -| -------- | ------------------------------------------------------------ | ------------ | --------- | -| -h | 主机名 | 否 | 127.0.0.1 | -| -p | 端口号 | 否 | 6667 | -| -u | 用户名 | 否 | root | -| -pw | 密码 | 否 | root | -| -t | 目标文件目录,用于指定输出文件应该保存到的目录 | 是 | - | -| -tfn | 导出文件的名称 | 否 | - | -| -q | 想要执行的查询命令的数量,可能用于批量执行查询 | 否 | - | -| -s | SQL 文件路径,用于指定包含要执行的 SQL 语句的文件位置 | 否 | - | -| -timeout | 会话查询的超时时间,用于指定查询操作在自动终止前允许的最长时间 | 否 | - | - -除此之外,如果没有使用`-s`和`-q`参数,在导出脚本被启动之后你需要按照程序提示输入查询语句,不同的查询结果会被保存到不同的TsFile文件中。 - -#### 3.3 运行示例 - -```Bash -# Unix/OS X -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 - -# Windows -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 +#### 2.2.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |--------------------------------------| +| -dt | --datatype | 是否在CSV文件的表头输出时间序列的数据类型,可以选择`true`或`false` | 否 | false | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601 | +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.2.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` -## 4. export-data 脚本 +### 2.3 Sql 格式 -支持 CSV:纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造 +#### 2.3.1 运行命令 -支持 SQL:包含自定义 SQL 语句的文件 - -#### 4.1 运行命令 - -```Bash +```Shell # Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + # Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] ``` -#### 4.2 参数介绍 - -| **参数** | **定义** | **是否必填** | **默认** | -| --------- | ------------------------------------------------------------ | ------------ | ------------------------ | -| -h | 主机名 | 否 | 127.0.0.1 | -| -p | 端口号 | 否 | 6667 | -| -u | 用户名 | 否 | root | -| -pw | 密码 | 否 | root | -| -t | 导出的 CSV 或 SQL 文件的输出路径(V1.3.2版本参数是`-td`) | 是 | | -| -datatype | 是否在 CSV 文件的 header 中时间序列的后面打印出对应的数据类型,选项为 true 或者 false | 否 | true | -| -q | 在命令中直接指定想要执行的查询语句(目前仅支持部分语句,详细明细见下表)说明:-q 与 -s 参数必填其一,同时填写则 -q 生效。详细支持的 SQL 语句示例,请参考下方“SQL语句支持明细” | 否 | | -| -s | 指定 SQL 文件,该文件可包含一条或多条 SQL 语句。如果包含多条 SQL 语句,语句之间应该用换行(回车)进行分割。每一条 SQL 语句对应一个或多个输出的CSV或 SQL 文件说明:-q 与 -s 参数必填其一,同时填写则-q生效。详细支持的 SQL 语句示例,请参考下方“SQL语句支持规则” | 否 | | -| -type | 指定导出的文件类型,选项为 csv 或者 sql | 否 | csv | -| -tf | 指定时间格式。时间格式必须遵守[ISO 8601](https://calendars.wikia.org/wiki/ISO_8601)标准,或时间戳(`timestamp`) 说明:只在 -type 为 csv 时生效 | 否 | yyyy-MM-dd HH:mm:ss.SSSz | -| -lpf | 指定导出的 dump 文件最大行数(V1.3.2版本参数是`-linesPerFile`) | 否 | 10000 | -| -timeout | 指定 session 查询时的超时时间,单位为ms | 否 | -1 | - -#### 4.3 SQL 语句支持规则 - -1. 只支持查询语句,非查询语句(如:元数据管理、系统管理等语句)不支持。对于不支持的 SQL ,程序会自动跳过,同时输出错误信息。 -2. 查询语句中目前版本仅支持原始数据的导出,如果有使用 group by、聚合函数、udf、操作运算符等则不支持导出为 SQL。原始数据导出时请注意,若导出多个设备数据,请使用 align by device 语句。详细示例如下: - -| | **支持导出** | **示例** | -| ----------------------------------------- | ------------ | --------------------------------------------- | -| 原始数据单设备查询 | 支持 | select * from root.s_0.d_0 | -| 原始数据多设备查询(aligin by device) | 支持 | select * from root.** align by device | -| 原始数据多设备查询(无 aligin by device) | 不支持 | select * from root.**select * from root.s_0.* | - -#### 4.4 运行示例 - -- 导出某 SQL 执行范围下的所有数据至 CSV 文件。 - -```Bash -# Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - -# Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] +#### 2.3.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------- | +| -aligned | --use\_aligned | 是否导出为对齐的SQL格式 | 否 | true | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601| +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.3.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` -- 导出结果 +### 2.4 TsFile 格式 -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 -``` - -- 导出 SQL 文件内所有 SQL 执行范围下的所有数据至 CSV 文件。 +#### 2.4.1 运行命令 -```Bash +```Shell # Unix/OS X ->tools/export-data.sh -t ./data/ -s export.sql +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + # Windows ->tools/export-data.bat -t ./data/ -s export.sql +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] ``` -- export.sql 文件内容(-s 参数指向的文件) +#### 2.4.2 私有参数 -```Bash -select * from root.stock.** limit 100 -select * from root.db.** limit 100 -``` +* 无 -- 导出结果文件1 +#### 2.4.3 运行示例: -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 +```Shell +# 正确示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# 异常示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` - -- 导出结果文件2 - -```Bash -Time,root.db.Random.RandomBoolean -2024-07-22T17:16:05.820+08:00,true -2024-07-22T17:16:02.597+08:00,false -``` - -- 将 IoTDB 数据库中在 SQL 文件内定义的数据,以对齐的格式将其导出为 SQL 语句。 - -```Bash -# Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -# Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -``` - -- 导出结果 - -```Bash -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249629831,0.62308747,2.0,0.012206747854849653,-6.0,false,0.14164352); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249630834,0.7520042,3.0,0.22760657101910464,-5.0,true,0.089064896); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249631835,0.3981064,3.0,0.6254559288663467,-6.0,false,0.9767922); -``` - -- 将某 SQL 执行范围下的所有数据导出至 CSV 文件,指定导出的时间格式为`yyyy-MM-dd HH:mm:ss`,且表头时间序列的后面打印出对应的数据类型。 - -```Bash -# Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -# Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -``` - -- 导出结果 - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice(DOUBLE),root.stock.Legacy.0700HK.Type(DOUBLE),root.stock.Legacy.0700HK.L1_BidSize(DOUBLE),root.stock.Legacy.0700HK.Domain(DOUBLE),root.stock.Legacy.0700HK.L1_BuyNo(BOOLEAN),root.stock.Legacy.0700HK.L1_AskPrice(DOUBLE) -2024-07-30 10:33:55,0.44574088,3.0,0.21476832811611501,-4.0,true,0.5951748 -2024-07-30 10:33:56,0.6880933,3.0,0.6289119476165305,-5.0,false,0.114634395 -``` \ No newline at end of file diff --git a/src/zh/UserGuide/V1.3.x/Tools-System/Data-Export-Tool-1-3-4.md b/src/zh/UserGuide/V1.3.x/Tools-System/Data-Export-Tool-1-3-4.md new file mode 100644 index 000000000..e4d1fc09b --- /dev/null +++ b/src/zh/UserGuide/V1.3.x/Tools-System/Data-Export-Tool-1-3-4.md @@ -0,0 +1,150 @@ +# 数据导出 + +## 1. 功能概述 + +数据导出工具 export-data.sh/bat 位于 tools 目录下,能够将指定 SQL 的查询结果导出为 CSV、SQL 及 TsFile(开源时间序列文件格式)格式。具体功能如下: + + + + + + + + + + + + + + + + + + + + + +
文件格式IoTDB工具具体介绍
CSVexport-data.sh/bat纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造
SQL包含自定义 SQL 语句的文件
TsFile开源时序数据文件格式
+ + +## 2. 功能详解 + +### 2.1 公共参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | ---------------------- | ---------------------------------------------------------------------- | -------------- | ------------------------------------------ | +| -ft | --file\_type | 导出文件的类型,可以选择:csv、sql、tsfile | √ | | +| -h | -- host | 主机名 | 否 | 127.0.0.1 | +| -p | --port | 端口号 | 否 | 6667 | +| -u | --username | 用户名 | 否 | root | +| -pw | --password | 密码 | 否 | root | +| -t | --target | 指定输出文件的目标文件夹,如果路径不存在新建文件夹 | √ | | +| -pfn | --prefix\_file\_name | 指定导出文件的名称。例如:abc,生成的文件是abc\_0.tsfile、abc\_1.tsfile | 否 | dump\_0.tsfile | +| -q | --query | 要执行的查询命令 | 否 | 无 | +| -timeout | --query\_timeout | 会话查询的超时时间(ms) | 否 | -1
范围:-1~Long max=9223372036854775807 | +| -help | --help | 显示帮助信息 | 否 | | + +### 2.2 Csv 格式 + +#### 2.2.1 运行命令 + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +# Windows +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +``` + +#### 2.2.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |--------------------------------------| +| -dt | --datatype | 是否在CSV文件的表头输出时间序列的数据类型,可以选择`true`或`false` | 否 | false | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601 | +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.2.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` + +### 2.3 Sql 格式 + +#### 2.3.1 运行命令 + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + +# Windows +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] +``` + +#### 2.3.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------- | +| -aligned | --use\_aligned | 是否导出为对齐的SQL格式 | 否 | true | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601| +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.3.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` + +### 2.4 TsFile 格式 + +#### 2.4.1 运行命令 + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + +# Windows +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] +``` + +#### 2.4.2 私有参数 + +* 无 + +#### 2.4.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# 异常示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` diff --git a/src/zh/UserGuide/dev-1.3/Tools-System/Data-Export-Tool-1-3-4.md b/src/zh/UserGuide/dev-1.3/Tools-System/Data-Export-Tool-1-3-4.md new file mode 100644 index 000000000..e4d1fc09b --- /dev/null +++ b/src/zh/UserGuide/dev-1.3/Tools-System/Data-Export-Tool-1-3-4.md @@ -0,0 +1,150 @@ +# 数据导出 + +## 1. 功能概述 + +数据导出工具 export-data.sh/bat 位于 tools 目录下,能够将指定 SQL 的查询结果导出为 CSV、SQL 及 TsFile(开源时间序列文件格式)格式。具体功能如下: + + + + + + + + + + + + + + + + + + + + + +
文件格式IoTDB工具具体介绍
CSVexport-data.sh/bat纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造
SQL包含自定义 SQL 语句的文件
TsFile开源时序数据文件格式
+ + +## 2. 功能详解 + +### 2.1 公共参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | ---------------------- | ---------------------------------------------------------------------- | -------------- | ------------------------------------------ | +| -ft | --file\_type | 导出文件的类型,可以选择:csv、sql、tsfile | √ | | +| -h | -- host | 主机名 | 否 | 127.0.0.1 | +| -p | --port | 端口号 | 否 | 6667 | +| -u | --username | 用户名 | 否 | root | +| -pw | --password | 密码 | 否 | root | +| -t | --target | 指定输出文件的目标文件夹,如果路径不存在新建文件夹 | √ | | +| -pfn | --prefix\_file\_name | 指定导出文件的名称。例如:abc,生成的文件是abc\_0.tsfile、abc\_1.tsfile | 否 | dump\_0.tsfile | +| -q | --query | 要执行的查询命令 | 否 | 无 | +| -timeout | --query\_timeout | 会话查询的超时时间(ms) | 否 | -1
范围:-1~Long max=9223372036854775807 | +| -help | --help | 显示帮助信息 | 否 | | + +### 2.2 Csv 格式 + +#### 2.2.1 运行命令 + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +# Windows +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] +``` + +#### 2.2.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |--------------------------------------| +| -dt | --datatype | 是否在CSV文件的表头输出时间序列的数据类型,可以选择`true`或`false` | 否 | false | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601 | +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.2.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` + +### 2.3 Sql 格式 + +#### 2.3.1 运行命令 + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + +# Windows +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] +``` + +#### 2.3.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------- | +| -aligned | --use\_aligned | 是否导出为对齐的SQL格式 | 否 | true | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601| +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.3.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` + +### 2.4 TsFile 格式 + +#### 2.4.1 运行命令 + +```Shell +# Unix/OS X +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + +# Windows +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] +``` + +#### 2.4.2 私有参数 + +* 无 + +#### 2.4.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# 异常示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t +``` diff --git a/src/zh/UserGuide/latest/Tools-System/Data-Export-Tool.md b/src/zh/UserGuide/latest/Tools-System/Data-Export-Tool.md index 361d5076e..e4d1fc09b 100644 --- a/src/zh/UserGuide/latest/Tools-System/Data-Export-Tool.md +++ b/src/zh/UserGuide/latest/Tools-System/Data-Export-Tool.md @@ -1,199 +1,150 @@ # 数据导出 -## 1. 导出工具介绍 - -导出工具可以将 SQL 查询的数据导出为指定的格式,包含用于导出 TsFile 文件的 `export-tsfile.sh/bat` 脚本和支持 CSV 和 SQL 格式的导出的 `export-data.sh/bat` 脚本。 - -## 2. 支持的数据类型 - -- CSV:纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造 - -- SQL:包含自定义 SQL 语句的文件 - -- TsFile: IoTDB 中使用的时间序列的文件格式 - -## 3. export-tsfile 脚本 - -支持 TsFile: IoTDB 中使用的时间序列的文件格式 - -#### 3.1 运行命令 - -```Bash +## 1. 功能概述 + +数据导出工具 export-data.sh/bat 位于 tools 目录下,能够将指定 SQL 的查询结果导出为 CSV、SQL 及 TsFile(开源时间序列文件格式)格式。具体功能如下: + + + + + + + + + + + + + + + + + + + + + +
文件格式IoTDB工具具体介绍
CSVexport-data.sh/bat纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造
SQL包含自定义 SQL 语句的文件
TsFile开源时序数据文件格式
+ + +## 2. 功能详解 + +### 2.1 公共参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | ---------------------- | ---------------------------------------------------------------------- | -------------- | ------------------------------------------ | +| -ft | --file\_type | 导出文件的类型,可以选择:csv、sql、tsfile | √ | | +| -h | -- host | 主机名 | 否 | 127.0.0.1 | +| -p | --port | 端口号 | 否 | 6667 | +| -u | --username | 用户名 | 否 | root | +| -pw | --password | 密码 | 否 | root | +| -t | --target | 指定输出文件的目标文件夹,如果路径不存在新建文件夹 | √ | | +| -pfn | --prefix\_file\_name | 指定导出文件的名称。例如:abc,生成的文件是abc\_0.tsfile、abc\_1.tsfile | 否 | dump\_0.tsfile | +| -q | --query | 要执行的查询命令 | 否 | 无 | +| -timeout | --query\_timeout | 会话查询的超时时间(ms) | 否 | -1
范围:-1~Long max=9223372036854775807 | +| -help | --help | 显示帮助信息 | 否 | | + +### 2.2 Csv 格式 + +#### 2.2.1 运行命令 + +```Shell # Unix/OS X -tools/export-tsfile.sh -h -p -u -pw -td [-f -q -s ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] # Windows -tools\export-tsfile.bat -h -p -u -pw -td [-f -q -s ] +> tools\export-data.bat -ft [-h ] [-p ] [-u ] [-pw ] -t + [-pfn ] [-dt ] [-lpf ] [-tf ] + [-tz ] [-q ] [-timeout ] ``` -#### 3.2 参数介绍 - -| **参数** | **定义** | **是否必填** | **默认** | -| -------- | ------------------------------------------------------------ | ------------ | --------- | -| -h | 主机名 | 否 | 127.0.0.1 | -| -p | 端口号 | 否 | 6667 | -| -u | 用户名 | 否 | root | -| -pw | 密码 | 否 | root | -| -t | 目标文件目录,用于指定输出文件应该保存到的目录 | 是 | - | -| -tfn | 导出文件的名称 | 否 | - | -| -q | 想要执行的查询命令的数量,可能用于批量执行查询 | 否 | - | -| -s | SQL 文件路径,用于指定包含要执行的 SQL 语句的文件位置 | 否 | - | -| -timeout | 会话查询的超时时间,用于指定查询操作在自动终止前允许的最长时间 | 否 | - | - -除此之外,如果没有使用`-s`和`-q`参数,在导出脚本被启动之后你需要按照程序提示输入查询语句,不同的查询结果会被保存到不同的TsFile文件中。 - -#### 3.3 运行示例 - -```Bash -# Unix/OS X -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 - -# Windows -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -q "select * from root.**" -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -# Or -tools/export-tsfile.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -# Or -tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s ./sql.txt -f myTsFile -t 10000 +#### 2.2.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |--------------------------------------| +| -dt | --datatype | 是否在CSV文件的表头输出时间序列的数据类型,可以选择`true`或`false` | 否 | false | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601 | +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.2.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -dt true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft csv -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` -## 4. export-data 脚本 +### 2.3 Sql 格式 -支持 CSV:纯文本格式,存储格式化数据,需按照下文指定 CSV 格式进行构造 +#### 2.3.1 运行命令 -支持 SQL:包含自定义 SQL 语句的文件 - -#### 4.1 运行命令 - -```Bash +```Shell # Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-aligned ] + -lpf - [-tf ] [-tz ] [-q ] [-timeout ] + # Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] +> tools\export-data.bat -ft [-h -p -u -pw ] + -t [-pfn -aligned + -lpf -tf -tz -q -timeout ] ``` -#### 4.2 参数介绍 - -| **参数** | **定义** | **是否必填** | **默认** | -| --------- | ------------------------------------------------------------ | ------------ | ------------------------ | -| -h | 主机名 | 否 | 127.0.0.1 | -| -p | 端口号 | 否 | 6667 | -| -u | 用户名 | 否 | root | -| -pw | 密码 | 否 | root | -| -t | 导出的 CSV 或 SQL 文件的输出路径(V1.3.2版本参数是`-td`) | 是 | | -| -datatype | 是否在 CSV 文件的 header 中时间序列的后面打印出对应的数据类型,选项为 true 或者 false | 否 | true | -| -q | 在命令中直接指定想要执行的查询语句(目前仅支持部分语句,详细明细见下表)说明:-q 与 -s 参数必填其一,同时填写则 -q 生效。详细支持的 SQL 语句示例,请参考下方“SQL语句支持明细” | 否 | | -| -s | 指定 SQL 文件,该文件可包含一条或多条 SQL 语句。如果包含多条 SQL 语句,语句之间应该用换行(回车)进行分割。每一条 SQL 语句对应一个或多个输出的CSV或 SQL 文件说明:-q 与 -s 参数必填其一,同时填写则-q生效。详细支持的 SQL 语句示例,请参考下方“SQL语句支持规则” | 否 | | -| -type | 指定导出的文件类型,选项为 csv 或者 sql | 否 | csv | -| -tf | 指定时间格式。时间格式必须遵守[ISO 8601](https://calendars.wikia.org/wiki/ISO_8601)标准,或时间戳(`timestamp`) 说明:只在 -type 为 csv 时生效 | 否 | yyyy-MM-dd HH:mm:ss.SSSz | -| -lpf | 指定导出的 dump 文件最大行数(V1.3.2版本参数是`-linesPerFile`) | 否 | 10000 | -| -timeout | 指定 session 查询时的超时时间,单位为ms | 否 | -1 | - -#### 4.3 SQL 语句支持规则 - -1. 只支持查询语句,非查询语句(如:元数据管理、系统管理等语句)不支持。对于不支持的 SQL ,程序会自动跳过,同时输出错误信息。 -2. 查询语句中目前版本仅支持原始数据的导出,如果有使用 group by、聚合函数、udf、操作运算符等则不支持导出为 SQL。原始数据导出时请注意,若导出多个设备数据,请使用 align by device 语句。详细示例如下: - -| | **支持导出** | **示例** | -| ----------------------------------------- | ------------ | --------------------------------------------- | -| 原始数据单设备查询 | 支持 | select * from root.s_0.d_0 | -| 原始数据多设备查询(aligin by device) | 支持 | select * from root.** align by device | -| 原始数据多设备查询(无 aligin by device) | 不支持 | select * from root.**select * from root.s_0.* | - -#### 4.4 运行示例 - -- 导出某 SQL 执行范围下的所有数据至 CSV 文件。 - -```Bash -# Unix/OS X ->tools/export-data.sh -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] - -# Windows ->tools\export-data.bat -h -p -u -pw -t [-tf -datatype -q -s -tfn -lpf -type -aligned ] +#### 2.3.2 私有参数 + +| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 | +| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------- | +| -aligned | --use\_aligned | 是否导出为对齐的SQL格式 | 否 | true | +| -lpf | --lines\_per\_file | 每个转储文件的行数 | 否 | 10000
范围:0~Integer.Max=2147483647 | +| -tf | --time\_format | 指定CSV文件中的时间格式。可以选择:1) 时间戳(数字、长整型);2) ISO8601(默认);3) 用户自定义模式,如`yyyy-MM-dd HH:mm:ss`(默认为ISO8601)。SQL文件中的时间戳输出不受时间格式设置影响 | 否| ISO8601| +| -tz | --timezone | 设置时区,例如`+08:00`或`-01:00` | 否 | 本机系统时间 | + +#### 2.3.3 运行示例: + +```Shell +# 正确示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn exported-data.csv -aligned true -lpf 1000 -tf "yyyy-MM-dd HH:mm:ss" + -tz +08:00 -q "SELECT * FROM root.ln" -timeout 20000 + +# 异常示例 +> tools/export-data.sh -ft sql -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` -- 导出结果 +### 2.4 TsFile 格式 -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 -``` - -- 导出 SQL 文件内所有 SQL 执行范围下的所有数据至 CSV 文件。 +#### 2.4.1 运行命令 -```Bash +```Shell # Unix/OS X ->tools/export-data.sh -t ./data/ -s export.sql +> tools/export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] + # Windows ->tools/export-data.bat -t ./data/ -s export.sql +> tools\export-data.sh -ft [-h ] [-p ] [-u ] [-pw ] + -t [-pfn ] [-q ] [-timeout ] ``` -- export.sql 文件内容(-s 参数指向的文件) +#### 2.4.2 私有参数 -```Bash -select * from root.stock.** limit 100 -select * from root.db.** limit 100 -``` +* 无 -- 导出结果文件1 +#### 2.4.3 运行示例: -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice,root.stock.Legacy.0700HK.Type,root.stock.Legacy.0700HK.L1_BidSize,root.stock.Legacy.0700HK.Domain,root.stock.Legacy.0700HK.L1_BuyNo,root.stock.Legacy.0700HK.L1_AskPrice -2024-07-29T18:37:18.700+08:00,0.9666617,3.0,0.021367407654674264,-6.0,false,0.8926191 -2024-07-29T18:37:19.701+08:00,0.3057328,3.0,0.9965377284981661,-5.0,false,0.15167356 +```Shell +# 正确示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root -t /path/export/dir + -pfn export-data.tsfile -q "SELECT * FROM root.ln" -timeout 10000 + +# 异常示例 +> tools/export-data.sh -ft tsfile -h 127.0.0.1 -p 6667 -u root -pw root +Parse error: Missing required option: t ``` - -- 导出结果文件2 - -```Bash -Time,root.db.Random.RandomBoolean -2024-07-22T17:16:05.820+08:00,true -2024-07-22T17:16:02.597+08:00,false -``` - -- 将 IoTDB 数据库中在 SQL 文件内定义的数据,以对齐的格式将其导出为 SQL 语句。 - -```Bash -# Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -# Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -``` - -- 导出结果 - -```Bash -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249629831,0.62308747,2.0,0.012206747854849653,-6.0,false,0.14164352); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249630834,0.7520042,3.0,0.22760657101910464,-5.0,true,0.089064896); -INSERT INTO root.stock.Legacy.0700HK(TIMESTAMP,L1_BidPrice,Type,L1_BidSize,Domain,L1_BuyNo,L1_AskPrice) ALIGNED VALUES (1722249631835,0.3981064,3.0,0.6254559288663467,-6.0,false,0.9767922); -``` - -- 将某 SQL 执行范围下的所有数据导出至 CSV 文件,指定导出的时间格式为`yyyy-MM-dd HH:mm:ss`,且表头时间序列的后面打印出对应的数据类型。 - -```Bash -# Unix/OS X ->tools/export-data.sh -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -# Windows ->tools/export-data.bat -h 127.0.0.1 -p 6667 -u root -p root -t ./data/ -s export.sql -type sql -aligned true -``` - -- 导出结果 - -```Bash -Time,root.stock.Legacy.0700HK.L1_BidPrice(DOUBLE),root.stock.Legacy.0700HK.Type(DOUBLE),root.stock.Legacy.0700HK.L1_BidSize(DOUBLE),root.stock.Legacy.0700HK.Domain(DOUBLE),root.stock.Legacy.0700HK.L1_BuyNo(BOOLEAN),root.stock.Legacy.0700HK.L1_AskPrice(DOUBLE) -2024-07-30 10:33:55,0.44574088,3.0,0.21476832811611501,-4.0,true,0.5951748 -2024-07-30 10:33:56,0.6880933,3.0,0.6289119476165305,-5.0,false,0.114634395 -``` \ No newline at end of file