diff --git a/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md b/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md index 6b7bb0cb1..1aacb9d3b 100644 --- a/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md +++ b/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md @@ -105,82 +105,6 @@ CREATE TABLE tableC ( Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution. -#### 1.1.2 Automatically Create Tables via SESSION - -Tables can be created automatically when inserting data via session. - -**Examples:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // Insert data without manually creating the table - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -After the code execution is complete, you can use the following statement to verify that the table has been successfully created, including details about the time column, tag columns, attribute columns, and field columns. - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 View Tables Used to view all tables and their properties in the current or a specified database. diff --git a/src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md b/src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md index 7e2e628ac..112f90f6a 100644 --- a/src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md +++ b/src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md @@ -105,82 +105,6 @@ CREATE TABLE tableC ( Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution. -#### 1.1.2 Automatically Create Tables via SESSION - -Tables can be created automatically when inserting data via session. - -**Examples:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // Insert data without manually creating the table - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -After the code execution is complete, you can use the following statement to verify that the table has been successfully created, including details about the time column, tag columns, attribute columns, and field columns. - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 View Tables Used to view all tables and their properties in the current or a specified database. diff --git a/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md b/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md index 6b7bb0cb1..1aacb9d3b 100644 --- a/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md +++ b/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md @@ -105,82 +105,6 @@ CREATE TABLE tableC ( Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution. -#### 1.1.2 Automatically Create Tables via SESSION - -Tables can be created automatically when inserting data via session. - -**Examples:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // Insert data without manually creating the table - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -After the code execution is complete, you can use the following statement to verify that the table has been successfully created, including details about the time column, tag columns, attribute columns, and field columns. - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 View Tables Used to view all tables and their properties in the current or a specified database. diff --git a/src/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md b/src/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md index 7e2e628ac..112f90f6a 100644 --- a/src/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md +++ b/src/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md @@ -105,82 +105,6 @@ CREATE TABLE tableC ( Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution. -#### 1.1.2 Automatically Create Tables via SESSION - -Tables can be created automatically when inserting data via session. - -**Examples:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // Insert data without manually creating the table - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -After the code execution is complete, you can use the following statement to verify that the table has been successfully created, including details about the time column, tag columns, attribute columns, and field columns. - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 View Tables Used to view all tables and their properties in the current or a specified database. diff --git a/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md b/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md index cc403027c..cff2f64f3 100644 --- a/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md +++ b/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md @@ -112,82 +112,6 @@ CREATE TABLE tableC ( 注意:若您使用的终端不支持多行粘贴(例如 Windows CMD),请将 SQL 语句调整为单行格式后再执行。 -#### 1.1.2 通过 Session 写入自动创建表 - -在通过 Session 进行数据写入时,IoTDB 能够根据写入请求中的信息自动构建表结构,无需用户事先手动创建表即可直接执行数据写入操作。 - -**示例:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // 不创建表直接写入数据 - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -在代码执行完成后,可以通过下述语句确认表已成功创建,其中包含了时间列、标签列、属性列以及测点列等各类信息。 - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 查看表 用于查看该数据库中或指定数据库中的所有表和表库的属性信息。 diff --git a/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md b/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md index ed4b890a8..32294fb21 100644 --- a/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md +++ b/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md @@ -112,82 +112,6 @@ CREATE TABLE tableC ( 注意:若您使用的终端不支持多行粘贴(例如 Windows CMD),请将 SQL 语句调整为单行格式后再执行。 -#### 1.1.2 通过 Session 写入自动创建表 - -在通过 Session 进行数据写入时,IoTDB 能够根据写入请求中的信息自动构建表结构,无需用户事先手动创建表即可直接执行数据写入操作。 - -**示例:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // 不创建表直接写入数据 - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -在代码执行完成后,可以通过下述语句确认表已成功创建,其中包含了时间列、标签列、属性列以及测点列等各类信息。 - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 查看表 用于查看该数据库中或指定数据库中的所有表和表库的属性信息。 diff --git a/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md b/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md index cc403027c..cff2f64f3 100644 --- a/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md +++ b/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md @@ -112,82 +112,6 @@ CREATE TABLE tableC ( 注意:若您使用的终端不支持多行粘贴(例如 Windows CMD),请将 SQL 语句调整为单行格式后再执行。 -#### 1.1.2 通过 Session 写入自动创建表 - -在通过 Session 进行数据写入时,IoTDB 能够根据写入请求中的信息自动构建表结构,无需用户事先手动创建表即可直接执行数据写入操作。 - -**示例:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // 不创建表直接写入数据 - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -在代码执行完成后,可以通过下述语句确认表已成功创建,其中包含了时间列、标签列、属性列以及测点列等各类信息。 - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 查看表 用于查看该数据库中或指定数据库中的所有表和表库的属性信息。 diff --git a/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md b/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md index ed4b890a8..32294fb21 100644 --- a/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md +++ b/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md @@ -112,82 +112,6 @@ CREATE TABLE tableC ( 注意:若您使用的终端不支持多行粘贴(例如 Windows CMD),请将 SQL 语句调整为单行格式后再执行。 -#### 1.1.2 通过 Session 写入自动创建表 - -在通过 Session 进行数据写入时,IoTDB 能够根据写入请求中的信息自动构建表结构,无需用户事先手动创建表即可直接执行数据写入操作。 - -**示例:** - -```Java -try (ITableSession session = - new TableSessionBuilder() - .nodeUrls(Collections.singletonList("127.0.0.1:6667")) - .username("root") - .password("root") - .build()) { - - session.executeNonQueryStatement("CREATE DATABASE db1"); - session.executeNonQueryStatement("use db1"); - - // 不创建表直接写入数据 - List columnNameList = - Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity"); - List dataTypeList = - Arrays.asList( - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.STRING, - TSDataType.FLOAT, - TSDataType.DOUBLE); - List columnTypeList = - new ArrayList<>( - Arrays.asList( - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.TAG, - ColumnCategory.ATTRIBUTE, - ColumnCategory.FIELD, - ColumnCategory.FIELD)); - Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100); - for (long timestamp = 0; timestamp < 100; timestamp++) { - int rowIndex = tablet.getRowSize(); - tablet.addTimestamp(rowIndex, timestamp); - tablet.addValue("region_id", rowIndex, "1"); - tablet.addValue("plant_id", rowIndex, "5"); - tablet.addValue("device_id", rowIndex, "3"); - tablet.addValue("model", rowIndex, "A"); - tablet.addValue("temperature", rowIndex, 37.6F); - tablet.addValue("humidity", rowIndex, 111.1); - if (tablet.getRowSize() == tablet.getMaxRowNumber()) { - session.insert(tablet); - tablet.reset(); - } - } - if (tablet.getRowSize() != 0) { - session.insert(tablet); - tablet.reset(); - } -} -``` - -在代码执行完成后,可以通过下述语句确认表已成功创建,其中包含了时间列、标签列、属性列以及测点列等各类信息。 - -```SQL -IoTDB> desc table1 -+-----------+---------+-----------+-------+ -| ColumnName| DataType| Category|Comment| -+-----------+---------+-----------+-------+ -| time|TIMESTAMP| TIME| null| -| region_id| STRING| TAG| null| -| plant_id| STRING| TAG| null| -| device_id| STRING| TAG| null| -| model| STRING| ATTRIBUTE| null| -|temperature| FLOAT| FIELD| null| -| humidity| DOUBLE| FIELD| null| -+-----------+---------+-----------+-------+ -``` - ### 1.2 查看表 用于查看该数据库中或指定数据库中的所有表和表库的属性信息。