From: | Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> |
---|---|
To: | CSN <cool_screen_name90001(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: autoupdate sequences after copy |
Date: | 2003-10-09 20:49:52 |
Message-ID: | 20031009214952.B3560@quartz.newn.cam.ac.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Oct 09, 2003 at 12:10:44PM -0700, CSN wrote:
> On Thursday 09 October 2003 08:10, CSN wrote:
> > Is there a way to have p/k sequences get
> automatically
> > set to max(id)+1 after COPY's like the following?
> >
> > copy table1 (id,name) from stdin;
> > 1 abc
> > 2 def
> > 3 fhi
> > \.
>
> Not really - if you don't use the sequence it keeps
> its value. If you look at
> pg_dump it issues an explicit setval() after a copy.
The problem is when you do
pg_dump -s -t table database > schema
pg_dump -a -t table database > data
edit data
psql -f schema otherdatabase
psql -f data otherdatabase
you then need to quickly
select setval('col_id_seq',(select max(id) from col));
for each sequence.. and not forget..
Cheers,
Patrick
From | Date | Subject | |
---|---|---|---|
Next Message | postgres | 2003-10-09 20:58:00 | Indexes, multicolumn or not? |
Previous Message | Joe Conway | 2003-10-09 20:36:05 | Re: int1? |