Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: Is this a b...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 15495 of 17437
Post > Topic >>

Re: Is this a bug? (changing sequences in default value)

by fernando@[EMAIL PROTECTED] (Fernando Schapachnik) May 9, 2008 at 09:55 AM

En un mensaje anterior, Merlin Moncure escribió:
> On Thu, May 8, 2008 at 7:52 AM, Fernando Schapachnik
> <fschapachnik@[EMAIL PROTECTED]
> wrote:
> > Pg 8.1.11, I try to change sequences as default value of a table, then
> > remove old sequence:
> >
> > # \d table1
> >                               Table "table1"
> >  Column |  Type   |                           Modifiers
> >
--------+---------+---------------------------------------------------------------
> >  id     | integer | not null default
nextval('table1_id_seq'::regclass)
> >  nombre | text    | not null
> > Indexes:
> >    "table1_pkey" PRIMARY KEY, btree (id)
> >
> > # ALTER TABLE table1 alter column id set default
nextval('newseq_id_seq');
> > ALTER TABLE
> >
> > # \d table1
> >                               Table "table1"
> >  Column |  Type   |                           Modifiers
> >
--------+---------+---------------------------------------------------------------
> >  id     | integer | not null default
nextval('newseq_id_seq'::regclass)
> >  nombre | text    | not null
> > Indexes:
> >    "table1_pkey" PRIMARY KEY, btree (id)
> >
> > # drop SEQUENCE table1_id_seq ;
> > ERROR:  cannot drop sequence table1_id_seq because table
> > table1 column id requires it
> > HINT:  You may drop table table1 column id instead.
> >
> > Am I doing something wrong?
> 
> yes and no  when you created the table initially you probably made it
> a 'serial' column which set up the owner****p that prevents the drop
> operation.  that owner****p did not go away when you altered the
> default to the new serial.
> 
> to fix this,
> alter sequence sequence table1_id_seq owned by none; -- now you can drop

Hi, Merlin. Thanks for the tip, but it doesn't work. Every variation 
of this syntax I tried gives me error as, apparently, it should:

\h ALTER SEQUENCE
Command:     ALTER SEQUENCE
Description: change the definition of a sequence generator
Syntax:
ALTER SEQUENCE name [ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO 
MAXVALUE ]
    [ RESTART [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]

Thanks again!

Fernando.

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 7 Posts in Topic:
Is this a bug? (changing sequences in default value)
fschapachnik@[EMAIL PROTE  2008-05-08 08:52:07 
Re: Is this a bug? (changing sequences in default value)
mmoncure@[EMAIL PROTECTED  2008-05-09 08:45:19 
Re: Is this a bug? (changing sequences in default value)
fernando@[EMAIL PROTECTED  2008-05-09 09:55:02 
Re: Is this a bug? (changing sequences in default value)
mmoncure@[EMAIL PROTECTED  2008-05-09 09:48:07 
Re: Is this a bug? (changing sequences in default value)
fernando@[EMAIL PROTECTED  2008-05-13 09:50:27 
Re: Is this a bug? (changing sequences in default value)
mmoncure@[EMAIL PROTECTED  2008-05-13 11:26:52 
Re: Is this a bug? (changing sequences in default value)
fernando@[EMAIL PROTECTED  2008-05-13 13:16:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 13:09:10 CST 2008.