Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: show create table for postgres_foreign_table #1391

Merged
merged 1 commit into from
Dec 20, 2024
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
15 changes: 14 additions & 1 deletion docs/user-guide/protocols/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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` 等。

Expand Down
Loading