Skip to content

Commit fd329d9

Browse files
leto-bbqCritasWang
authored andcommitted
remove session from create table (apache#1031)
1 parent 0ace69b commit fd329d9

8 files changed

Lines changed: 0 additions & 608 deletions

File tree

src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -105,82 +105,6 @@ CREATE TABLE tableC (
105105

106106
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.
107107

108-
#### 1.1.2 Automatically Create Tables via SESSION
109-
110-
Tables can be created automatically when inserting data via session.
111-
112-
**Examples:**
113-
114-
```Java
115-
try (ITableSession session =
116-
new TableSessionBuilder()
117-
.nodeUrls(Collections.singletonList("127.0.0.1:6667"))
118-
.username("root")
119-
.password("root")
120-
.build()) {
121-
122-
session.executeNonQueryStatement("CREATE DATABASE db1");
123-
session.executeNonQueryStatement("use db1");
124-
125-
// Insert data without manually creating the table
126-
List<String> columnNameList =
127-
Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity");
128-
List<TSDataType> dataTypeList =
129-
Arrays.asList(
130-
TSDataType.STRING,
131-
TSDataType.STRING,
132-
TSDataType.STRING,
133-
TSDataType.STRING,
134-
TSDataType.FLOAT,
135-
TSDataType.DOUBLE);
136-
List<ColumnCategory> columnTypeList =
137-
new ArrayList<>(
138-
Arrays.asList(
139-
ColumnCategory.TAG,
140-
ColumnCategory.TAG,
141-
ColumnCategory.TAG,
142-
ColumnCategory.ATTRIBUTE,
143-
ColumnCategory.FIELD,
144-
ColumnCategory.FIELD));
145-
Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100);
146-
for (long timestamp = 0; timestamp < 100; timestamp++) {
147-
int rowIndex = tablet.getRowSize();
148-
tablet.addTimestamp(rowIndex, timestamp);
149-
tablet.addValue("region_id", rowIndex, "1");
150-
tablet.addValue("plant_id", rowIndex, "5");
151-
tablet.addValue("device_id", rowIndex, "3");
152-
tablet.addValue("model", rowIndex, "A");
153-
tablet.addValue("temperature", rowIndex, 37.6F);
154-
tablet.addValue("humidity", rowIndex, 111.1);
155-
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
156-
session.insert(tablet);
157-
tablet.reset();
158-
}
159-
}
160-
if (tablet.getRowSize() != 0) {
161-
session.insert(tablet);
162-
tablet.reset();
163-
}
164-
}
165-
```
166-
167-
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.
168-
169-
```SQL
170-
IoTDB> desc table1
171-
+-----------+---------+-----------+-------+
172-
| ColumnName| DataType| Category|Comment|
173-
+-----------+---------+-----------+-------+
174-
| time|TIMESTAMP| TIME| null|
175-
| region_id| STRING| TAG| null|
176-
| plant_id| STRING| TAG| null|
177-
| device_id| STRING| TAG| null|
178-
| model| STRING| ATTRIBUTE| null|
179-
|temperature| FLOAT| FIELD| null|
180-
| humidity| DOUBLE| FIELD| null|
181-
+-----------+---------+-----------+-------+
182-
```
183-
184108
### 1.2 View Tables
185109

186110
Used to view all tables and their properties in the current or a specified database.

src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -105,82 +105,6 @@ CREATE TABLE tableC (
105105

106106
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.
107107

108-
#### 1.1.2 Automatically Create Tables via SESSION
109-
110-
Tables can be created automatically when inserting data via session.
111-
112-
**Examples:**
113-
114-
```Java
115-
try (ITableSession session =
116-
new TableSessionBuilder()
117-
.nodeUrls(Collections.singletonList("127.0.0.1:6667"))
118-
.username("root")
119-
.password("root")
120-
.build()) {
121-
122-
session.executeNonQueryStatement("CREATE DATABASE db1");
123-
session.executeNonQueryStatement("use db1");
124-
125-
// Insert data without manually creating the table
126-
List<String> columnNameList =
127-
Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity");
128-
List<TSDataType> dataTypeList =
129-
Arrays.asList(
130-
TSDataType.STRING,
131-
TSDataType.STRING,
132-
TSDataType.STRING,
133-
TSDataType.STRING,
134-
TSDataType.FLOAT,
135-
TSDataType.DOUBLE);
136-
List<ColumnCategory> columnTypeList =
137-
new ArrayList<>(
138-
Arrays.asList(
139-
ColumnCategory.TAG,
140-
ColumnCategory.TAG,
141-
ColumnCategory.TAG,
142-
ColumnCategory.ATTRIBUTE,
143-
ColumnCategory.FIELD,
144-
ColumnCategory.FIELD));
145-
Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100);
146-
for (long timestamp = 0; timestamp < 100; timestamp++) {
147-
int rowIndex = tablet.getRowSize();
148-
tablet.addTimestamp(rowIndex, timestamp);
149-
tablet.addValue("region_id", rowIndex, "1");
150-
tablet.addValue("plant_id", rowIndex, "5");
151-
tablet.addValue("device_id", rowIndex, "3");
152-
tablet.addValue("model", rowIndex, "A");
153-
tablet.addValue("temperature", rowIndex, 37.6F);
154-
tablet.addValue("humidity", rowIndex, 111.1);
155-
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
156-
session.insert(tablet);
157-
tablet.reset();
158-
}
159-
}
160-
if (tablet.getRowSize() != 0) {
161-
session.insert(tablet);
162-
tablet.reset();
163-
}
164-
}
165-
```
166-
167-
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.
168-
169-
```SQL
170-
IoTDB> desc table1
171-
+-----------+---------+-----------+-------+
172-
| ColumnName| DataType| Category|Comment|
173-
+-----------+---------+-----------+-------+
174-
| time|TIMESTAMP| TIME| null|
175-
| region_id| STRING| TAG| null|
176-
| plant_id| STRING| TAG| null|
177-
| device_id| STRING| TAG| null|
178-
| model| STRING| ATTRIBUTE| null|
179-
|temperature| FLOAT| FIELD| null|
180-
| humidity| DOUBLE| FIELD| null|
181-
+-----------+---------+-----------+-------+
182-
```
183-
184108
### 1.2 View Tables
185109

186110
Used to view all tables and their properties in the current or a specified database.

src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -105,82 +105,6 @@ CREATE TABLE tableC (
105105

106106
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.
107107

108-
#### 1.1.2 Automatically Create Tables via SESSION
109-
110-
Tables can be created automatically when inserting data via session.
111-
112-
**Examples:**
113-
114-
```Java
115-
try (ITableSession session =
116-
new TableSessionBuilder()
117-
.nodeUrls(Collections.singletonList("127.0.0.1:6667"))
118-
.username("root")
119-
.password("root")
120-
.build()) {
121-
122-
session.executeNonQueryStatement("CREATE DATABASE db1");
123-
session.executeNonQueryStatement("use db1");
124-
125-
// Insert data without manually creating the table
126-
List<String> columnNameList =
127-
Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity");
128-
List<TSDataType> dataTypeList =
129-
Arrays.asList(
130-
TSDataType.STRING,
131-
TSDataType.STRING,
132-
TSDataType.STRING,
133-
TSDataType.STRING,
134-
TSDataType.FLOAT,
135-
TSDataType.DOUBLE);
136-
List<ColumnCategory> columnTypeList =
137-
new ArrayList<>(
138-
Arrays.asList(
139-
ColumnCategory.TAG,
140-
ColumnCategory.TAG,
141-
ColumnCategory.TAG,
142-
ColumnCategory.ATTRIBUTE,
143-
ColumnCategory.FIELD,
144-
ColumnCategory.FIELD));
145-
Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100);
146-
for (long timestamp = 0; timestamp < 100; timestamp++) {
147-
int rowIndex = tablet.getRowSize();
148-
tablet.addTimestamp(rowIndex, timestamp);
149-
tablet.addValue("region_id", rowIndex, "1");
150-
tablet.addValue("plant_id", rowIndex, "5");
151-
tablet.addValue("device_id", rowIndex, "3");
152-
tablet.addValue("model", rowIndex, "A");
153-
tablet.addValue("temperature", rowIndex, 37.6F);
154-
tablet.addValue("humidity", rowIndex, 111.1);
155-
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
156-
session.insert(tablet);
157-
tablet.reset();
158-
}
159-
}
160-
if (tablet.getRowSize() != 0) {
161-
session.insert(tablet);
162-
tablet.reset();
163-
}
164-
}
165-
```
166-
167-
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.
168-
169-
```SQL
170-
IoTDB> desc table1
171-
+-----------+---------+-----------+-------+
172-
| ColumnName| DataType| Category|Comment|
173-
+-----------+---------+-----------+-------+
174-
| time|TIMESTAMP| TIME| null|
175-
| region_id| STRING| TAG| null|
176-
| plant_id| STRING| TAG| null|
177-
| device_id| STRING| TAG| null|
178-
| model| STRING| ATTRIBUTE| null|
179-
|temperature| FLOAT| FIELD| null|
180-
| humidity| DOUBLE| FIELD| null|
181-
+-----------+---------+-----------+-------+
182-
```
183-
184108
### 1.2 View Tables
185109

186110
Used to view all tables and their properties in the current or a specified database.

src/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -105,82 +105,6 @@ CREATE TABLE tableC (
105105

106106
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.
107107

108-
#### 1.1.2 Automatically Create Tables via SESSION
109-
110-
Tables can be created automatically when inserting data via session.
111-
112-
**Examples:**
113-
114-
```Java
115-
try (ITableSession session =
116-
new TableSessionBuilder()
117-
.nodeUrls(Collections.singletonList("127.0.0.1:6667"))
118-
.username("root")
119-
.password("root")
120-
.build()) {
121-
122-
session.executeNonQueryStatement("CREATE DATABASE db1");
123-
session.executeNonQueryStatement("use db1");
124-
125-
// Insert data without manually creating the table
126-
List<String> columnNameList =
127-
Arrays.asList("region_id", "plant_id", "device_id", "model", "temperature", "humidity");
128-
List<TSDataType> dataTypeList =
129-
Arrays.asList(
130-
TSDataType.STRING,
131-
TSDataType.STRING,
132-
TSDataType.STRING,
133-
TSDataType.STRING,
134-
TSDataType.FLOAT,
135-
TSDataType.DOUBLE);
136-
List<ColumnCategory> columnTypeList =
137-
new ArrayList<>(
138-
Arrays.asList(
139-
ColumnCategory.TAG,
140-
ColumnCategory.TAG,
141-
ColumnCategory.TAG,
142-
ColumnCategory.ATTRIBUTE,
143-
ColumnCategory.FIELD,
144-
ColumnCategory.FIELD));
145-
Tablet tablet = new Tablet("table1", columnNameList, dataTypeList, columnTypeList, 100);
146-
for (long timestamp = 0; timestamp < 100; timestamp++) {
147-
int rowIndex = tablet.getRowSize();
148-
tablet.addTimestamp(rowIndex, timestamp);
149-
tablet.addValue("region_id", rowIndex, "1");
150-
tablet.addValue("plant_id", rowIndex, "5");
151-
tablet.addValue("device_id", rowIndex, "3");
152-
tablet.addValue("model", rowIndex, "A");
153-
tablet.addValue("temperature", rowIndex, 37.6F);
154-
tablet.addValue("humidity", rowIndex, 111.1);
155-
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
156-
session.insert(tablet);
157-
tablet.reset();
158-
}
159-
}
160-
if (tablet.getRowSize() != 0) {
161-
session.insert(tablet);
162-
tablet.reset();
163-
}
164-
}
165-
```
166-
167-
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.
168-
169-
```SQL
170-
IoTDB> desc table1
171-
+-----------+---------+-----------+-------+
172-
| ColumnName| DataType| Category|Comment|
173-
+-----------+---------+-----------+-------+
174-
| time|TIMESTAMP| TIME| null|
175-
| region_id| STRING| TAG| null|
176-
| plant_id| STRING| TAG| null|
177-
| device_id| STRING| TAG| null|
178-
| model| STRING| ATTRIBUTE| null|
179-
|temperature| FLOAT| FIELD| null|
180-
| humidity| DOUBLE| FIELD| null|
181-
+-----------+---------+-----------+-------+
182-
```
183-
184108
### 1.2 View Tables
185109

186110
Used to view all tables and their properties in the current or a specified database.

0 commit comments

Comments
 (0)