Re: [GENERAL] alter sequence

2012-12-02 Thread Guillaume Lelarge
On Sun, 2012-12-02 at 11:42 +, Jasen Betts wrote: > On 2012-11-24, Peter Kroon wrote: > > --f46d04389321c8f47d04cf3c0f32 > > Content-Type: text/plain; charset=ISO-8859-1 > > > > ALTER SEQUENCE (select pg_get_serial_sequence('table', 'id')) RESTART WITH > > 1; > > > The query fails: > > ALTER

Re: [GENERAL] alter sequence

2012-12-02 Thread Jasen Betts
On 2012-11-24, Peter Kroon wrote: > --f46d04389321c8f47d04cf3c0f32 > Content-Type: text/plain; charset=ISO-8859-1 > > ALTER SEQUENCE (select pg_get_serial_sequence('table', 'id')) RESTART WITH > 1; > The query fails: > ALTER SEQUENCE (select pg_get_serial_sequence('table... > it's because of the

Re: [GENERAL] alter sequence

2012-11-24 Thread Pavel Stehule
Hello you can't to do it directly. Expression cannot be used instead object name you can use a plpgsql DO in this moment DO $$ BEGIN EXECUTE format('ALTER SEQUENCE %I RESTART WITH 1', pg_get_serial_sequence('table', 'id')); END; $$ LANGUAGE plpgsql; Regards Pavel Stehule 2012/11/24 Peter Kr

[GENERAL] alter sequence

2012-11-24 Thread Peter Kroon
ALTER SEQUENCE (select pg_get_serial_sequence('table', 'id')) RESTART WITH 1; The query fails: ALTER SEQUENCE (select pg_get_serial_sequence('table... it's because of the ( I guess I'm using the wrong syntax. It is possible this way? Would be great! Best, Peter

Re: [GENERAL] Alter sequence restart with selected value...

2007-09-18 Thread Jeff Ross
Scott Marlowe wrote: On 9/18/07, Jeff Ross <[EMAIL PROTECTED]> wrote: I'm using copy to insert a bunch of rows into a new table with a unique primary key. Copy is correctly incrementing the primary key, but apparently the sequence itself is never updated because when I go to insert again I get

Re: [GENERAL] Alter sequence restart with selected value...

2007-09-18 Thread Scott Marlowe
On 9/18/07, Jeff Ross <[EMAIL PROTECTED]> wrote: > I'm using copy to insert a bunch of rows into a new table with a unique > primary key. Copy is correctly incrementing the primary key, but > apparently the sequence itself is never updated because when I go to > insert again I get a constraint vio

[GENERAL] Alter sequence restart with selected value...

2007-09-18 Thread Jeff Ross
I'm using copy to insert a bunch of rows into a new table with a unique primary key. Copy is correctly incrementing the primary key, but apparently the sequence itself is never updated because when I go to insert again I get a constraint violation. Here's the start of the new table creation: CR

Re: [GENERAL] ALTER SEQUENCE ... RESTART WITH [variable] problem

2006-05-22 Thread Jim C. Nasby
On Sat, May 20, 2006 at 11:46:25AM +0200, Tomi NA wrote: > On 5/20/06, Martijn van Oosterhout wrote: > > >Seems you can't use a variable there. Your choices are to build a > >string and use EXECUTE, or just do: > > > >SELECT setval('sequence',value); > > The EXECUTE string solution did the job.

Re: [GENERAL] ALTER SEQUENCE

2006-05-22 Thread Jim C. Nasby
On Thu, May 18, 2006 at 11:42:02PM -0700, Don Y wrote: > We aren't populating tables. Most of our work is involved > in the things *around* the database (the database is just a > small piece of the puzzle). I, for example, drop all of > my tables at the end of each work day -- along with most > o

Re: [GENERAL] ALTER SEQUENCE

2006-05-22 Thread Jim C. Nasby
On Fri, May 19, 2006 at 02:08:01AM -0400, Tom Lane wrote: > Don Y <[EMAIL PROTECTED]> writes: > > Jim C. Nasby wrote: > >> This is a very minor reason why you should be running the most recent > >> 8.0.x release and not 8.0.3. A much bigger reason is that there are > >> data-loss bugs that have bee

Re: [GENERAL] ALTER SEQUENCE ... RESTART WITH [variable] problem

2006-05-20 Thread Tomi NA
On 5/20/06, Martijn van Oosterhout wrote: Seems you can't use a variable there. Your choices are to build a string and use EXECUTE, or just do: SELECT setval('sequence',value); The EXECUTE string solution did the job. Thank you very much, Martijn. t.n.a. ---(end of

Re: [GENERAL] ALTER SEQUENCE ... RESTART WITH [variable] problem

2006-05-20 Thread Martijn van Oosterhout
On Sat, May 20, 2006 at 09:52:29AM +0200, Tomi NA wrote: > I need to generate a couple of dozen statements reseting my sequences > so that they're next values are greater than the biggest existing ids. > The problem is, I can't even form a statement to update one sequence. > This is what I tried:

[GENERAL] ALTER SEQUENCE ... RESTART WITH [variable] problem

2006-05-20 Thread Tomi NA
I need to generate a couple of dozen statements reseting my sequences so that they're next values are greater than the biggest existing ids. The problem is, I can't even form a statement to update one sequence. This is what I tried: CREATE OR REPLACE FUNCTION init_sequences() RETURNS void AS $BOD

Re: [GENERAL] ALTER SEQUENCE

2006-05-18 Thread Don Y
Tom Lane wrote: Don Y <[EMAIL PROTECTED]> writes: Jim C. Nasby wrote: This is a very minor reason why you should be running the most recent 8.0.x release and not 8.0.3. A much bigger reason is that there are data-loss bugs that have been fixed. The folks watching the Postgres releases haven'

Re: [GENERAL] ALTER SEQUENCE

2006-05-18 Thread Tom Lane
Don Y <[EMAIL PROTECTED]> writes: > Jim C. Nasby wrote: >> This is a very minor reason why you should be running the most recent >> 8.0.x release and not 8.0.3. A much bigger reason is that there are >> data-loss bugs that have been fixed. > The folks watching the Postgres releases haven't yet sai

Re: [GENERAL] ALTER SEQUENCE

2006-05-18 Thread Don Y
Jim C. Nasby wrote: On Wed, May 17, 2006 at 03:00:48PM -0700, Don Y wrote: I see the documentation mention added August 1, 2005 byt Tom Lane. Date tag on the bottom of my man pages is "2005-01-17" -- so that explains *that*! :> This is a very minor reason why you should be running the most r

Re: [GENERAL] ALTER SEQUENCE

2006-05-17 Thread Jim C. Nasby
On Wed, May 17, 2006 at 03:00:48PM -0700, Don Y wrote: > >I see the documentation mention added August 1, 2005 byt Tom Lane. > > Date tag on the bottom of my man pages is "2005-01-17" -- so that > explains *that*! :> This is a very minor reason why you should be running the most recent 8.0.x rel

Re: [GENERAL] ALTER SEQUENCE

2006-05-17 Thread Bruce Momjian
Don Y wrote: > Bruce Momjian wrote: > > Don Y wrote: > >> Bruce Momjian wrote: > >>> Don Y wrote: > Hi, > > It doesn't appear that there is a way to rename a sequence > (ideally with a "cascade" action). > >>> > >>> Uh, the ALTER SEQUENCE manual page says: > >> Uh, the 8.0.3 man

Re: [GENERAL] ALTER SEQUENCE

2006-05-17 Thread Don Y
Bruce Momjian wrote: Don Y wrote: Bruce Momjian wrote: Don Y wrote: Hi, It doesn't appear that there is a way to rename a sequence (ideally with a "cascade" action). Uh, the ALTER SEQUENCE manual page says: Uh, the 8.0.3 man page for ALTER SEQUENCE makes no mention of this. Nor does "\h AL

Re: [GENERAL] ALTER SEQUENCE

2006-05-17 Thread Bruce Momjian
Don Y wrote: > Bruce Momjian wrote: > > Don Y wrote: > >> Hi, > >> > >> It doesn't appear that there is a way to rename a sequence > >> (ideally with a "cascade" action). > > > > > > Uh, the ALTER SEQUENCE manual page says: > > Uh, the 8.0.3 man page for ALTER SEQUENCE makes no mention of this.

Re: [GENERAL] ALTER SEQUENCE

2006-05-17 Thread Don Y
Bruce Momjian wrote: Don Y wrote: Hi, It doesn't appear that there is a way to rename a sequence (ideally with a "cascade" action). Uh, the ALTER SEQUENCE manual page says: Uh, the 8.0.3 man page for ALTER SEQUENCE makes no mention of this. Nor does "\h ALTER SEQUENCE" in psql yield any po

Re: [GENERAL] ALTER SEQUENCE

2006-05-17 Thread Bruce Momjian
Don Y wrote: > Hi, > > It doesn't appear that there is a way to rename a sequence > (ideally with a "cascade" action). Uh, the ALTER SEQUENCE manual page says: Some variants of ALTER TABLE can be used with sequences as well; for example, to rename a sequence use ALTER TABLE

[GENERAL] ALTER SEQUENCE

2006-05-17 Thread Don Y
Hi, It doesn't appear that there is a way to rename a sequence (ideally with a "cascade" action). Nor does there appear to be a way to change the owner of a sequence. Obviously, I can DROP and recreate... *but*, how prudent (foolish?) would it be just to change the entries in the system tables

[GENERAL] "alter sequence" equivilant in 7.2?

2004-06-20 Thread Shea Martin
I am moving my database from a machine running 7.4 to a machine running 7.2. My sequences are not out of wack, is there a way to set the current value of a sequence? I though ALTER SEQUENCE would work but it does not exist in version 7.2. Thanks, ~S ---(end of broadcast)

Re: [GENERAL] "alter sequence" equivilant in 7.2?

2004-06-20 Thread Shea Martin
Shea Martin wrote: I am moving my database from a machine running 7.4 to a machine running 7.2. My sequences are not out of wack, is there a way to set the current value of a sequence? I though ALTER SEQUENCE would work but it does not exist in version 7.2. Thanks, ~S I honestly did to google