首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >psql表描述

psql表描述
EN

Database Administration用户
提问于 2019-03-22 08:22:57
回答 1查看 340关注 0票数 0

在psql中,如果我做了\d+,我会得到以下内容

代码语言:javascript
复制
 Schema |          Name           |   Type   | Owner  |    Size    |     Description 
--------+-------------------------+----------+--------+------------+-------------
 norsar | Routing Result          | table    | morten | 16 kB      | 
 norsar | Routing Result_id_seq   | sequence | morten | 8192 bytes | 

诸若此类。最后一个字段“描述”总是空白的。该字段在哪里读取其内容?-因此,我如何在表上设置描述?在某些情况下,这是非常有用的--如果我执行\d+ <tablename>,在列上显示的描述也是一样的。

我试过\set ECHO_HIDDEN ON,但这并没有让它变得更清楚。

EN

回答 1

Database Administration用户

回答已采纳

发布于 2019-03-22 08:34:58

它显示了使用命令comment on定义的注释:

下表定义:

代码语言:javascript
复制
create table foo
(
  id integer primary key, 
  name text not null
);

comment on table foo is 'This is the famous foo table';
comment on column foo.id is 'This is the primary key';
comment on column foo.name is 'This is the name of the thing';

然后就会像这样出现:

代码语言:javascript
复制
postgres> \d+
                                List of relations
 Schema |   Name    | Type  | Owner  |    Size    |         Description
--------+-----------+-------+--------+------------+------------------------------
 public | foo       | table | thomas | 8192 bytes | This is the famous foo table
(1 row)

postgres> \d+ foo
                                             Table "public.foo"
 Column |  Type   | Collation | Nullable | Default | Storage  | Stats target |          Description
--------+---------+-----------+----------+---------+----------+--------------+-------------------------------
 id     | integer |           | not null |         | plain    |              | This is the primary key
 name   | text    |           | not null |         | extended |              | This is the name of the thing
Indexes:
    "foo_pkey" PRIMARY KEY, btree (id)


postgres>
票数 3
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/232826

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档