# select c.relname table_name, pg_catalog.obj_description(c.oid) as comment
from pg_catalog.pg_class c where c.relname = 'old';
table_name | comment
------------+-------------
old | comment old
(1 row)
# alter table old rename to new;
ALTER TABLE
# select c.relname table_name, pg_catalog.obj_description(c.oid) as comment
from pg_catalog.pg_class c where c.relname = 'old';
table_name | comment
------------+---------
(0 rows)
# select c.relname table_name, pg_catalog.obj_description(c.oid) as comment
from pg_catalog.pg_class c where c.relname = 'new';
table_name | comment
------------+-------------
new | comment old
(1 row)
#
2条答案
按热度按时间u7up0aaq1#
你不必这么做
ALTER
评论。只是使用设置新注解。这将自动覆盖旧的注解。
评论不是
ALTER
ed或DROP
佩德。若要删除注解,请使用将其设置为nullCOMMENT ON
.pes8fvy92#
注解将随着表重命名而“移动”: