diff --git a/docs/nightly/en/faq-and-others/faq.md b/docs/nightly/en/faq-and-others/faq.md index 0f62e0d82..1d0b33c3a 100644 --- a/docs/nightly/en/faq-and-others/faq.md +++ b/docs/nightly/en/faq-and-others/faq.md @@ -85,7 +85,8 @@ Currently, GreptimeDB's compatibility efforts are primarily focused on the imple ## Should I use the command "drop database" to delete a database? -Yes, that is the intended command. However, 'drop database' will be implemented in v0.8. It is expected to be included in the next minor iterative update. As a result, there is no direct way to delete a database at the moment. You may consider creating a new database for testing purposes. If you're working with test data, you also have the option to clear it by deleting the data directory. +Yes, you can use `DROP DATABASE db_name` command to delete a database. +Please refer to the [DROP](/reference/sql/drop.md#drop-database) document for more details. ## Are there any retention policy? diff --git a/docs/nightly/en/reference/sql/drop.md b/docs/nightly/en/reference/sql/drop.md new file mode 100644 index 000000000..70b2ba612 --- /dev/null +++ b/docs/nightly/en/reference/sql/drop.md @@ -0,0 +1,57 @@ +# DROP + +## DROP DATABASE + +`DROP DATABASE` drops a database. It removes the catalog entries for the database and deletes the directory containing the data. + +:::danger Danger + +`DROP DATABASE` cannot be undone. Use it with care! + +::: + +### Syntax + +```sql +DROP DATABASE [ IF EXISTS ] db_name +``` + +- `IF EXISTS`: Do not throw an error if the database does not exist. +- `db_name`: The name of the database to remove. + +### Examples + +To drop a database named `test`: + +```sql +DROP DATABASE test; +``` + + +## DROP TABLE + +`DROP TABLE` removes tables from the database. It will remove the table definition and all table data, indexes, rules, and constraints for that table. + +:::danger Danger + +`DROP TABLE` cannot be undone. Use it with care! + +::: + +### Syntax + +```sql +DROP TABLE [ IF EXISTS ] table_name +``` + +- `IF EXISTS`: Do not throw an error if the table does not exist. +- `table_name`: The name of the table to remove. + + +### Examples + +Drop the table `monitor` in the current database: + +```sql +DROP TABLE monitor; +``` diff --git a/docs/nightly/en/summary.yml b/docs/nightly/en/summary.yml index 04ae724bb..011ad3530 100644 --- a/docs/nightly/en/summary.yml +++ b/docs/nightly/en/summary.yml @@ -146,6 +146,7 @@ - insert - cast - copy + - drop - select - distinct - where diff --git a/docs/nightly/en/user-guide/concepts/data-model.md b/docs/nightly/en/user-guide/concepts/data-model.md index ee113c826..d50941c71 100644 --- a/docs/nightly/en/user-guide/concepts/data-model.md +++ b/docs/nightly/en/user-guide/concepts/data-model.md @@ -41,7 +41,7 @@ Those are very similar to the table model everyone is familiar with. The differe These columns contain the actual data and are not indexed, but they can be efficiently computed and evaluated, such as the latest value, maximum/minimum value, average, percentage, and so on. Please avoid using `Field` columns in query conditions, which is highly resource-intensive and unperformant. -To learn how to indicate `Tag`, `Timestamp`, and `Field` columns, Please refer to [table management](../table-management.md#create-table) and [CREATE statement](/reference/sql/create.md). +To learn how to indicate `Tag`, `Timestamp`, and `Field` columns, Please refer to [table management](../table-management.md#create-a-table) and [CREATE statement](/reference/sql/create.md). ## Design Considerations diff --git a/docs/nightly/en/user-guide/query-data/sql.md b/docs/nightly/en/user-guide/query-data/sql.md index 342596303..8c40657dd 100644 --- a/docs/nightly/en/user-guide/query-data/sql.md +++ b/docs/nightly/en/user-guide/query-data/sql.md @@ -4,7 +4,7 @@ GreptimeDB supports full SQL for querying data from a database. In this document, we will use the `monitor` table to demonstrate how to query data. For instructions on creating the `monitor` table and inserting data into it, -Please refer to [table management](/user-guide/table-management.md#create-table) and [write data](/user-guide/write-data/sql.md). +Please refer to [table management](/user-guide/table-management.md#create-a-table) and [write data](/user-guide/write-data/sql.md). ## Basic query @@ -257,7 +257,7 @@ SELECT DISTINCT ON (host) * FROM monitor ORDER BY host, ts DESC; GreptimeDB supports [Range Query](/reference/sql/range.md) to aggregate data by time window. -Suppose we have the following data in the [`monitor` table](../table-management.md#create-table): +Suppose we have the following data in the [`monitor` table](../table-management.md#create-a-table): ```sql +-----------+---------------------+------+--------+ diff --git a/docs/nightly/en/user-guide/table-management.md b/docs/nightly/en/user-guide/table-management.md index 6b6d300e0..2d916e18c 100644 --- a/docs/nightly/en/user-guide/table-management.md +++ b/docs/nightly/en/user-guide/table-management.md @@ -7,7 +7,7 @@ uses [MySQL Command-Line Client](https://dev.mysql.com/doc/refman/8.0/en/mysql.h For more explanations of the `SQL` syntax, please see the [SQL reference](/reference/sql/overview.md). -## Create Database +## Create a database The default database is `public`. You can create a database manually. @@ -62,7 +62,7 @@ Change back to `public` database: USE public; ``` -## Create Table +## Create a table :::tip NOTE GreptimeDB offers a schemaless approach to writing data that eliminates the need to manually create tables using additional protocols. See [Automatic Schema Generation](/user-guide/write-data/overview.md#automatic-schema-generation). @@ -107,7 +107,7 @@ Therefore, it is important to carefully design your data model before creating t [1]: https://docs.influxdata.com/influxdb/v1.8/concepts/glossary/#tag-key [2]: https://docs.influxdata.com/influxdb/v1/concepts/glossary/#series -## Describe Table +## Describe a table Show table information in detail: @@ -178,7 +178,7 @@ SHOW TABLES FROM test; 1 row in set (0.01 sec) ``` -## Alter Table +## Alter a table You can alter the schema of existing tables just like in MySQL database @@ -200,7 +200,11 @@ Query OK, 0 rows affected (0.03 sec) Notice: currently only adding/dropping columns is allowed, altering column definition will soon be supported. -## Drop Table +## Drop a table + +:::danger danger +`DROP TABLE` cannot be undone. Use it with care! +::: `DROP TABLE [db.]table` is used to drop the table in `db` or the current database in-use.Drop the table `test` in the current database: @@ -212,9 +216,26 @@ DROP TABLE monitor; Query OK, 1 row affected (0.01 sec) ``` +## Drop a database + +:::danger danger +`DROP DATABASE` cannot be undone. Use it with care! +::: + +You can use `DROP DATABASE` to drop a database. +For example, to drop the `test` database: + +```sql +DROP DATABASE test; +``` + +Please refer to the [DROP](/reference/sql/drop.md#drop-database) document for more details. + ## HTTP API -Using the following code to create a table through POST method: +You can execute the SQL statements through the HTTP API. +For example, +using the following code to create a table through POST method: ```shell curl -X POST \ diff --git a/docs/nightly/en/user-guide/write-data/prometheus.md b/docs/nightly/en/user-guide/write-data/prometheus.md index 59422742e..5ad695010 100644 --- a/docs/nightly/en/user-guide/write-data/prometheus.md +++ b/docs/nightly/en/user-guide/write-data/prometheus.md @@ -24,7 +24,7 @@ Be sure to uncomment `basic_auth` section and replace `greptime_user(username)`, The `db` parameter in the URL represents the database that we want to write data. It's optional. By default, the database is `public`. -If you want to write to another database, you can [create a new database](../table-management.md#create-database) +If you want to write to another database, you can [create a new database](../table-management.md#create-a-database) and replace `public` with the new database name. GreptimeDB automatically groups multiple Prometheus metrics (../clients/prometheus#data-model) into the corresponding logical tables, so you do not need to specify the logical table in the URL of `remote_write`. diff --git a/docs/nightly/en/user-guide/write-data/sql.md b/docs/nightly/en/user-guide/write-data/sql.md index 5aafb55cd..94fd32da8 100644 --- a/docs/nightly/en/user-guide/write-data/sql.md +++ b/docs/nightly/en/user-guide/write-data/sql.md @@ -2,7 +2,7 @@ We will use the `monitor` table as an example to show how to write data. For the SQL example on how to create the `monitor` table, -Please refer to [table management](../table-management.md#create-table). +Please refer to [table management](../table-management.md#create-a-table). ## Insert data @@ -71,7 +71,7 @@ VALUES ("127.0.0.1", 1702433141000, 0.8, 0.1); ``` -As described in the [Create Table](../table-management.md#create-table) section, +As described in the [Create Table](../table-management.md#create-a-table) section, the `host` column represents the tag and the `ts` column represents the time index. To update the data, you can use the same `host` and `ts` values as the existing data and set the new `cpu` value to `0.5`: diff --git a/docs/nightly/zh/getting-started/installation/overview.md b/docs/nightly/zh/getting-started/installation/overview.md index 335bb1188..62480906a 100644 --- a/docs/nightly/zh/getting-started/installation/overview.md +++ b/docs/nightly/zh/getting-started/installation/overview.md @@ -1,4 +1,4 @@ -# 概览 +# 概述 - [GreptimeDB 单机模式](greptimedb-standalone.md) - [GreptimeDB 分布式集群](greptimedb-cluster.md) diff --git a/docs/nightly/zh/getting-started/overview.md b/docs/nightly/zh/getting-started/overview.md index 6b94b2fa4..a7a61bfc6 100644 --- a/docs/nightly/zh/getting-started/overview.md +++ b/docs/nightly/zh/getting-started/overview.md @@ -1,4 +1,4 @@ -# 概览 +# 概述 立即开始使用 GreptimeDB! diff --git a/docs/nightly/zh/getting-started/quick-start/overview.md b/docs/nightly/zh/getting-started/quick-start/overview.md index 344eaf98a..c9aed090a 100644 --- a/docs/nightly/zh/getting-started/quick-start/overview.md +++ b/docs/nightly/zh/getting-started/quick-start/overview.md @@ -1,4 +1,4 @@ -# 概览 +# 概述 使用你熟悉的协议或语言快速上手 GreptimeDB! 在这些文档中,我们将以 CPU 使用率为例,快速地感受 GreptimeDB 的基本用法。 diff --git a/docs/nightly/zh/greptimecloud/usage-&-billing/overview.md b/docs/nightly/zh/greptimecloud/usage-&-billing/overview.md index 1623fcfda..ea57fa052 100644 --- a/docs/nightly/zh/greptimecloud/usage-&-billing/overview.md +++ b/docs/nightly/zh/greptimecloud/usage-&-billing/overview.md @@ -1,4 +1,4 @@ -# 概览 +# 概述 此文档将帮助你了解 GreptimeCloud 的用量和费用。 diff --git a/docs/nightly/zh/reference/sql/drop.md b/docs/nightly/zh/reference/sql/drop.md new file mode 100644 index 000000000..0ba67511b --- /dev/null +++ b/docs/nightly/zh/reference/sql/drop.md @@ -0,0 +1,55 @@ +# DROP + +## DROP DATABASE + +`DROP DATABASE` 用于删除数据库,它删除数据库的目录项并删除包含数据的目录。 + +:::danger 危险操作 + +`DROP DATABASE` 无法撤消。请谨慎使用! + +::: + +### 语法 + +```sql +DROP DATABASE [ IF EXISTS ] db_name +``` + +- `IF EXISTS`: 如果数据库不存在,则不抛出错误。 +- `db_name`: 要删除的数据库的名称。 + +### 示例 + +删除名为 `test` 的数据库: + +```sql +DROP DATABASE test; +``` + +## DROP TABLE + +`DROP TABLE` 从数据库中删除表,它将删除该表的表定义和所有表数据、索引、规则和约束。 + +:::danger 危险操作 + +`DROP TABLE` 无法撤消。请谨慎使用! + +::: + +### 语法 + +```sql +DROP TABLE [ IF EXISTS ] table_name +``` + +- `IF EXISTS`: 如果表不存在,则不抛出错误。 +- `table_name`: 要删除的表的名称。 + +### 示例 + +删除 `monitor` 表: + +```sql +DROP TABLE monitor; +``` diff --git a/docs/nightly/zh/user-guide/concepts/data-model.md b/docs/nightly/zh/user-guide/concepts/data-model.md index f1966af5e..4ce909e43 100644 --- a/docs/nightly/zh/user-guide/concepts/data-model.md +++ b/docs/nightly/zh/user-guide/concepts/data-model.md @@ -23,7 +23,7 @@ GreptimeDB 中的所有数据都被组织成表,每个表中的数据项由三 - `Field` 列中的 `cpu_util`、`memory_util`、`disk_util` 和 `load` 列分别表示机器的 CPU 利用率、内存利用率、磁盘利用率和负载。 这些列包含实际的数据并且不被索引。应当避免在查询条件中使用 `Field` 列,这会消耗大量资源并且性能较差。 -要了解如何指定 `Tag`、`Timestamp` 和 `Field` 列,请参见[表管理](../table-management.md#create-table)和 [CREATE 语句](/reference/sql/create.md)。 +要了解如何指定 `Tag`、`Timestamp` 和 `Field` 列,请参见[表管理](../table-management.md#创建表)和 [CREATE 语句](/reference/sql/create.md)。 ## 设计考虑 diff --git a/docs/nightly/zh/user-guide/table-management.md b/docs/nightly/zh/user-guide/table-management.md index 9e757b7f3..bcddd0281 100644 --- a/docs/nightly/zh/user-guide/table-management.md +++ b/docs/nightly/zh/user-guide/table-management.md @@ -199,6 +199,10 @@ Query OK, 0 rows affected (0.03 sec) ## 删除表 +:::danger 危险操作 +表删除后不可撤销!请谨慎操作! +::: + `DROP TABLE [db.]table` 用于删除 `db` 或当前正在使用的数据库中的表。 删除当前数据库中的表 `test`: @@ -211,6 +215,21 @@ DROP TABLE monitor; Query OK, 1 row affected (0.01 sec) ``` +## 删除数据库 + +:::danger 危险操作 +数据库删除后不可撤销!请谨慎操作! +::: + +可以使用 `DROP DATABASE` 删除数据库。 +例如,删除 `test` 数据库: + +```sql +DROP DATABASE test; +``` + +请前往 [DROP](/reference/sql/drop.md#drop-database) 文档了解更多内容。 + ## HTTP API 使用以下代码,通过 POST 方法创建一个表: diff --git a/docs/nightly/zh/user-guide/write-data/prometheus.md b/docs/nightly/zh/user-guide/write-data/prometheus.md index 04e340596..9d5f9fbb2 100644 --- a/docs/nightly/zh/user-guide/write-data/prometheus.md +++ b/docs/nightly/zh/user-guide/write-data/prometheus.md @@ -23,7 +23,7 @@ remote_read: ::: URL 中的 `db` 参数表示我们要写入的数据库,是可选的,默认为 `public`。 -如果你想要写入到其他数据库,可以[创建新数据库](../table-management.md#create-database)并将 `public` 替换为新的数据库名称。 +如果你想要写入到其他数据库,可以[创建新数据库](../table-management.md#create-a-database)并将 `public` 替换为新的数据库名称。 GreptimeDB 将多个 Prometheus 指标[自动组合](../clients/prometheus#数据模型)到相应的逻辑表中,因此你无需在 `remote_write` 的 URL 中指定逻辑表。