diff --git a/docs/user-guide/protocols/postgresql.md b/docs/user-guide/protocols/postgresql.md index 4af3e627f..2e173362e 100644 --- a/docs/user-guide/protocols/postgresql.md +++ b/docs/user-guide/protocols/postgresql.md @@ -127,7 +127,8 @@ CREATE TABLE app_logs ( ) with('append_mode'='true'); ``` -You will need to define them like this in Postgres. +The foreign table DDL is like this. You need to run them in Postgres to create +these tables; ```sql CREATE FOREIGN TABLE ft_grpc_latencies ( @@ -150,6 +151,18 @@ SERVER greptimedb OPTIONS (table_name 'app_logs'); ``` +To help you to generate statements in Postgres, we enhanced `SHOW CREATE TABLE` +in GreptimeDB to dump the Postgres DDL for you. For example: + +```sql +SHOW CREATE TABLE grpc_latencies FOR postgres_foreign_table; +``` + +Note that you will need to replace server name `greptimedb` with the name you +defined in `CREATE SERVER` statement. + +### Run Queries + You can now send query from Postgres. It's also possible to use functions that are available in both Postgres and GreptimeDB, like `date_trunc`. diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/postgresql.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/postgresql.md index c09f1daf1..68678c614 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/postgresql.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/postgresql.md @@ -146,6 +146,18 @@ SERVER greptimedb OPTIONS (table_name 'app_logs'); ``` +为了帮助用户生成这些语句,我们在 GreptimeDB 里增强了 `SHOW CREATE TABLE` 来直接 +输出可执行的语句。 + +```sql +SHOW CREATE TABLE grpc_latencies FOR postgres_foreign_table; +``` + +注意在输出的语句中你需要把服务器名 `greptimedb` 替换为之前在 `CREATE SERVER` 语句 +里使用的名字。 + +### 执行查询 + 至此你可以通过 Postgres 发起查询。并且可以使用一些同时存在在 GreptimeDB 和 Postgres 上的函数,如 `date_trunc` 等。