|
1
5
接下来要知道的是如何获取表oid。正如你所怀疑的那样,我认为将此作为评论的一部分是行不通的。 postgres=# create table comtest1 (id int, val varchar);
CREATE TABLE
postgres=# insert into comtest1 values (1,'a');
INSERT 0 1
postgres=# select distinct tableoid from comtest1;
tableoid
----------
32792
(1 row)
postgres=# comment on column comtest1.id is 'Identifier Number One';
COMMENT
postgres=# select col_description(32792,1);
col_description
-----------------------
Identifier Number One
(1 row)
无论如何,我快速启动了一个plpgsql函数,将注释从一个表/列对复制到另一个表/列对。您必须在数据库上创建Lang plpgsql,并按如下方式使用它: Copy the comment on the first column of table comtest1 to the id
column of the table comtest2. Yes, it should be improved but
that's left as work for the reader.
postgres=# select copy_comment('comtest1',1,'comtest2','id');
copy_comment
--------------
1
(1 row)
|