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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ This command is used to create a database.
**Examples:**

```SQL
CREATE DATABASE database1;
CREATE DATABASE IF NOT EXISTS database1;

// Sets TTL to 1 year.
CREATE DATABASE IF NOT EXISTS database1 with(TTL=31536000000);
```

Expand All @@ -73,7 +69,7 @@ USE <DATABASE_NAME>
**Example:**

```SQL
USE database1
USE database1;
```

### 1.3 View the Current Database
Expand All @@ -89,23 +85,18 @@ SHOW CURRENT_DATABASE
**Example:**

```SQL
IoTDB> SHOW CURRENT_DATABASE;
+---------------+
|CurrentDatabase|
+---------------+
| null|
+---------------+

IoTDB> USE database1;

IoTDB> SHOW CURRENT_DATABASE;
USE database1;
SHOW CURRENT_DATABASE;
```
```shell
+---------------+
|CurrentDatabase|
+---------------+
| database1|
+---------------+
```


### 1.4 View All Databases

Displays all databases and their properties.
Expand All @@ -131,15 +122,9 @@ SHOW DATABASES (DETAILS)?
**Examples:**

```SQL
IoTDB> show databases
+------------------+-------+-----------------------+---------------------+---------------------+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+------------------+-------+-----------------------+---------------------+---------------------+
| database1| INF| 1| 1| 604800000|
|information_schema| INF| null| null| null|
+------------------+-------+-----------------------+---------------------+---------------------+

IoTDB> show databases details
SHOW DATABASES DETAILS;
```
```shell
+------------------+-------+-----------------------+---------------------+---------------------+--------------------+------------------+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|DataRegionGroupNum|
+------------------+-------+-----------------------+---------------------+---------------------+--------------------+------------------+
Expand Down Expand Up @@ -186,5 +171,5 @@ DROP DATABASE (IF EXISTS)? <DATABASE_NAME>
**Example:**

```SQL
DROP DATABASE IF EXISTS database1
DROP DATABASE IF EXISTS database1;
```
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ This command is used to create a database.
**Examples:**

```SQL
CREATE DATABASE database1;
CREATE DATABASE IF NOT EXISTS database1;

// Sets TTL to 1 year.
CREATE DATABASE IF NOT EXISTS database1 with(TTL=31536000000);
```

Expand All @@ -73,7 +69,7 @@ USE <DATABASE_NAME>
**Example:**

```SQL
USE database1
USE database1;
```

### 1.3 View the Current Database
Expand All @@ -89,23 +85,18 @@ SHOW CURRENT_DATABASE
**Example:**

```SQL
IoTDB> SHOW CURRENT_DATABASE;
+---------------+
|CurrentDatabase|
+---------------+
| null|
+---------------+

IoTDB> USE database1;

IoTDB> SHOW CURRENT_DATABASE;
USE database1;
SHOW CURRENT_DATABASE;
```
```shell
+---------------+
|CurrentDatabase|
+---------------+
| database1|
+---------------+
```


### 1.4 View All Databases

Displays all databases and their properties.
Expand All @@ -131,15 +122,9 @@ SHOW DATABASES (DETAILS)?
**Examples:**

```SQL
IoTDB> show databases
+------------------+-------+-----------------------+---------------------+---------------------+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+------------------+-------+-----------------------+---------------------+---------------------+
| database1| INF| 1| 1| 604800000|
|information_schema| INF| null| null| null|
+------------------+-------+-----------------------+---------------------+---------------------+

IoTDB> show databases details
SHOW DATABASES DETAILS;
```
```shell
+------------------+-------+-----------------------+---------------------+---------------------+--------------------+------------------+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|DataRegionGroupNum|
+------------------+-------+-----------------------+---------------------+---------------------+--------------------+------------------+
Expand Down Expand Up @@ -186,5 +171,5 @@ DROP DATABASE (IF EXISTS)? <DATABASE_NAME>
**Example:**

```SQL
DROP DATABASE IF EXISTS database1
DROP DATABASE IF EXISTS database1;
```
21 changes: 4 additions & 17 deletions src/UserGuide/Master/Table/Basic-Concept/Delete-Data.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,21 @@ The [Example Data page](../Reference/Sample-Data.md)page provides SQL statements
#### 1.2.1 Delet All Data from a Table

```SQL
# Whole table deletion
DELETE FROM table1
DELETE FROM table1;
```

#### 1.2.2 Delete Data within a Specific Time Range

```SQL
# Single time interval deletion
DELETE FROM table1 WHERE time <= 2024-11-29 00:00:00

# Multi time interval deletion
DELETE FROM table1 WHERE time >= 2024-11-27 00:00:00 and time <= 2024-11-29 00:00:00
DELETE FROM table1 WHERE time >= 2024-11-27 00:00:00 and time <= 2024-11-29 00:00:00;
```

#### 1.2.3 Deleting Data for a Specific Device

```SQL
# Device-specific deletion
# Identifier conditions only support the '=' operator
DELETE FROM table1 WHERE device_id='101' and model_id = 'B'

# Device-specific deletion with time interval
DELETE FROM table1
WHERE time >= 2024-11-27 16:39:00 and time <= 2024-11-29 16:42:00
AND device_id='101' and model_id = 'B'

# Device-type-specific deletion
DELETE FROM table1 WHERE model_id = 'B'
AND device_id='101' and model_id = 'B';
```

## 2. Device Deletion
Expand All @@ -117,5 +104,5 @@ DELETE DEVICES FROM tableName=qualifiedName (WHERE booleanExpression)?
### 2.2 Example

```SQL
DELETE DEVICES FROM table1 WHERE device_id = '101'
DELETE DEVICES FROM table1 WHERE device_id = '101';
```
36 changes: 18 additions & 18 deletions src/UserGuide/Master/Table/Basic-Concept/TTL-Delete-Data_apache.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ If TTL is specified when creating a table using SQL, the table’s TTL takes pre
Example 1: Setting TTL during table creation:

```SQL
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=3600)
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=3600);
```

Example 2: Changing TTL for an existing table:
Expand All @@ -59,9 +59,9 @@ ALTER TABLE tableB SET PROPERTIES TTL=3600;
**Example 3:** If TTL is not specified or set to the default value, it will inherit the database's TTL. By default, the database TTL is `'INF'` (infinite):

```SQL
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=DEFAULT)
CREATE TABLE test3 ("site" string id, "temperature" int32)
ALTER TABLE tableB set properties TTL=DEFAULT
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=DEFAULT);
CREATE TABLE test3 ("site" string id, "temperature" int32);
ALTER TABLE tableB set properties TTL=DEFAULT;
```

### 2.2 Set TTL for Databases
Expand All @@ -71,33 +71,33 @@ Tables without explicit TTL settings inherit the TTL of their database. Refer to
Example 4: A database with TTL=3600000 creates tables inheriting this TTL:

```SQL
CREATE DATABASE db WITH (ttl=3600000)
use db
CREATE TABLE test3 ("site" string id, "temperature" int32)
CREATE DATABASE db WITH (ttl=3600000);
use db;
CREATE TABLE test3 ("site" string id, "temperature" int32);
```

Example 5: A database without a TTL setting creates tables without TTL:

```SQL
CREATE DATABASE db
use db
CREATE TABLE test3 ("site" string id, "temperature" int32)
CREATE DATABASE db;
use db;
CREATE TABLE test3 ("site" string id, "temperature" int32);
```

Example 6: Setting a table with no TTL explicitly (TTL=INF) in a database with a configured TTL:

```SQL
CREATE DATABASE db WITH (ttl=3600000)
use db
CREATE TABLE test3 ("site" string id, "temperature" int32) with (ttl='INF')
CREATE DATABASE db WITH (ttl=3600000);
use db;
CREATE TABLE test3 ("site" string id, "temperature" int32) with (ttl='INF');
```

## 3. Remove TTL

To cancel a TTL setting, modify the table's TTL to 'INF'. Note that IoTDB does not currently support modifying the TTL of a database.

```SQL
ALTER TABLE tableB set properties TTL='INF'
ALTER TABLE tableB set properties TTL='INF';
```

## 4. View TTL Information
Expand All @@ -109,22 +109,22 @@ Use the SHOW DATABASES and SHOW TABLES commands to view TTL details for database
Example Output:

```SQL
IoTDB> show databases
IoTDB> show databases;
+---------+-------+-----------------------+---------------------+---------------------+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+---------+-------+-----------------------+---------------------+---------------------+
|test_prop| 300| 1| 3| 100000|
| test2| 300| 1| 1| 604800000|
+---------+-------+-----------------------+---------------------+---------------------+

IoTDB> show databases details
IoTDB> show databases details;
+---------+-------+-----------------------+---------------------+---------------------+-----+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|Model|
+---------+-------+-----------------------+---------------------+---------------------+-----+
|test_prop| 300| 1| 3| 100000|TABLE|
| test2| 300| 1| 1| 604800000| TREE|
+---------+-------+-----------------------+---------------------+---------------------+-----+
IoTDB> show tables
IoTDB> show tables;
+---------+-------+
|TableName|TTL(ms)|
+---------+-------+
Expand All @@ -133,7 +133,7 @@ IoTDB> show tables
| flower| INF|
+---------+-------+

IoTDB> show tables details
IoTDB> show tables details;
+---------+-------+----------+
|TableName|TTL(ms)| Status|
+---------+-------+----------+
Expand Down
36 changes: 18 additions & 18 deletions src/UserGuide/Master/Table/Basic-Concept/TTL-Delete-Data_timecho.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ If TTL is specified when creating a table using SQL, the table’s TTL takes pre
Example 1: Setting TTL during table creation:

```SQL
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=3600)
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=3600);
```

Example 2: Changing TTL for an existing table:
Expand All @@ -59,9 +59,9 @@ ALTER TABLE tableB SET PROPERTIES TTL=3600;
**Example 3:** If TTL is not specified or set to the default value, it will inherit the database's TTL. By default, the database TTL is `'INF'` (infinite):

```SQL
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=DEFAULT)
CREATE TABLE test3 ("site" string id, "temperature" int32)
ALTER TABLE tableB set properties TTL=DEFAULT
CREATE TABLE test3 ("site" string id, "temperature" int32) with (TTL=DEFAULT);
CREATE TABLE test3 ("site" string id, "temperature" int32);
ALTER TABLE tableB set properties TTL=DEFAULT;
```

### 2.2 Set TTL for Databases
Expand All @@ -71,33 +71,33 @@ Tables without explicit TTL settings inherit the TTL of their database. Refer to
Example 4: A database with TTL=3600000 creates tables inheriting this TTL:

```SQL
CREATE DATABASE db WITH (ttl=3600000)
use db
CREATE TABLE test3 ("site" string id, "temperature" int32)
CREATE DATABASE db WITH (ttl=3600000);
use db;
CREATE TABLE test3 ("site" string id, "temperature" int32);
```

Example 5: A database without a TTL setting creates tables without TTL:

```SQL
CREATE DATABASE db
use db
CREATE TABLE test3 ("site" string id, "temperature" int32)
CREATE DATABASE db;
use db;
CREATE TABLE test3 ("site" string id, "temperature" int32);
```

Example 6: Setting a table with no TTL explicitly (TTL=INF) in a database with a configured TTL:

```SQL
CREATE DATABASE db WITH (ttl=3600000)
use db
CREATE TABLE test3 ("site" string id, "temperature" int32) with (ttl='INF')
CREATE DATABASE db WITH (ttl=3600000);
use db;
CREATE TABLE test3 ("site" string id, "temperature" int32) with (ttl='INF');
```

## 3. Remove TTL

To cancel a TTL setting, modify the table's TTL to 'INF'. Note that IoTDB does not currently support modifying the TTL of a database.

```SQL
ALTER TABLE tableB set properties TTL='INF'
ALTER TABLE tableB set properties TTL='INF';
```

## 4. View TTL Information
Expand All @@ -109,22 +109,22 @@ Use the SHOW DATABASES and SHOW TABLES commands to view TTL details for database
Example Output:

```SQL
IoTDB> show databases
IoTDB> show databases;
+---------+-------+-----------------------+---------------------+---------------------+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+---------+-------+-----------------------+---------------------+---------------------+
|test_prop| 300| 1| 3| 100000|
| test2| 300| 1| 1| 604800000|
+---------+-------+-----------------------+---------------------+---------------------+

IoTDB> show databases details
IoTDB> show databases details;
+---------+-------+-----------------------+---------------------+---------------------+-----+
| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|Model|
+---------+-------+-----------------------+---------------------+---------------------+-----+
|test_prop| 300| 1| 3| 100000|TABLE|
| test2| 300| 1| 1| 604800000| TREE|
+---------+-------+-----------------------+---------------------+---------------------+-----+
IoTDB> show tables
IoTDB> show tables;
+---------+-------+
|TableName|TTL(ms)|
+---------+-------+
Expand All @@ -133,7 +133,7 @@ IoTDB> show tables
| flower| INF|
+---------+-------+

IoTDB> show tables details
IoTDB> show tables details;
+---------+-------+----------+
|TableName|TTL(ms)| Status|
+---------+-------+----------+
Expand Down
Loading
Loading