Обсуждение: ownership of sequences

Поиск
Список
Период
Сортировка

ownership of sequences

От
Chris
Дата:
Hi,

Is there an easy way to alter the owner of a sequence or does it have to be
created by the right user in the first place ?

foo=# create user a with nocreatedb nocreateuser;
foo=# create schema a authorization a;
foo=# create table a.a(id serial, name text);
foo=# set search_path='a';
foo=# \d
           List of relations
  Schema |   Name   |   Type   | Owner
--------+----------+----------+-------
  a      | a        | table    | pgsql
  a      | a_id_seq | sequence | pgsql
(2 rows)

foo=# alter table a owner to a;
foo=# \d
           List of relations
  Schema |   Name   |   Type   | Owner
--------+----------+----------+-------
  a      | a        | table    | a
  a      | a_id_seq | sequence | pgsql
(2 rows)

foo=# \c - a
foo=> insert into a(name) values ('blah');
ERROR:  a_id_seq.nextval: you don't have permissions to set sequence a_id_seq
foo=>


Re: ownership of sequences

От
Tom Lane
Дата:
Chris <pggeneral@designmagick.com> writes:
> Is there an easy way to alter the owner of a sequence or does it have to be
> created by the right user in the first place ?

ALTER TABLE ... OWNER ... works fine.

            regards, tom lane