ownership of sequences

Started by Chrisover 23 years ago2 messagesgeneral
Jump to latest
#1Chris
pggeneral@designmagick.com

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=>

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Chris (#1)
Re: ownership of sequences

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