Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 23rd, 2005, 02:23 AM
ben f
Guest
 
Posts: n/a
Default sequence rename?

So I am renaming a table, and the last stumbling block
that I've met is the associated sequence. I tried the
commands suggested @

http://mailman.fastxs.net/pipermail/...st/004307.html

ie:

CREATE SEQUENCE $newseq
SELECT setval('$newseq', max($column)) FROM $table
ALTER TABLE $table ALTER COLUMN $column SET DEFAULT
nextval('$newseq'::text)
DROP SEQUENCE $oldseq

but when trying to perform the DROP SEQUENCE (psql), i
get a message like:

ERROR: Cannot drop sequence $oldseq because table
$table column $column requires it
You may drop table $table column $column instead


After that, I tried the query suggested here:

http://www.commandprompt.com/ppbook/...OVINGASEQUENCE
(example 7-34)

And it came back empty.

What am I doing wrong? when i \d $table, it shows no
such dependency. Is there another way to pull this
off?

thanks

ben

ps -- please cc responses directly to me, since i'm
not a subscriber.



_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.
http://messenger.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

  #2  
Old November 23rd, 2005, 02:23 AM
Alvaro Herrera
Guest
 
Posts: n/a
Default Re: sequence rename?

On Fri, Oct 01, 2004 at 01:17:38PM -0700, ben f wrote:[color=blue]
> So I am renaming a table, and the last stumbling block
> that I've met is the associated sequence. I tried the
> commands suggested @
>
> http://mailman.fastxs.net/pipermail/...st/004307.html
>
> ie:
>
> CREATE SEQUENCE $newseq
> SELECT setval('$newseq', max($column)) FROM $table
> ALTER TABLE $table ALTER COLUMN $column SET DEFAULT
> nextval('$newseq'::text)
> DROP SEQUENCE $oldseq[/color]

How about

ALTER TABLE $oldseq RENAME TO $newseq;

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Y eso te lo doy firmado con mis lágrimas" (Fiebre del Loco)


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles