Re: copy from

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: copy from
Дата
Msg-id Pine.BSF.4.10.10008151056120.86873-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Re: copy from  ("Adam Lang" <aalang@rutgersinsurance.com>)
Список pgsql-sql
Sort of.  You can give the field a default value of
nextval(<sequence>) which means that if you do not specify
the column in an insert, it automatically gets the default
value which should be the next value in the sequence.
Note, that not putting the column is different from inserting a
NULL into the field.

(Example:
sszabo=# create sequence xyzseq; 
CREATE
sszabo=# create table xyzseqtest ( a int default nextval('xyzseq'), b
int);
CREATE
sszabo=# insert into xyzseqtest (b) values (2);
INSERT 172188 1
sszabo=# insert into xyzseqtest (b) values (3);
INSERT 172189 1
sszabo=# select * from xyzseqtest;a | b 
---+---1 | 22 | 3
(2 rows)
)

There are issues about this dealing with rules and triggers where another
row may be inserted or the default may be evaluated a second time where
you want to get the value you just inserted back, but in general it works.

On Tue, 15 Aug 2000, Adam Lang wrote:

> Hmmm... well, I don't think I have an "explicit" nextval.  I created the
> table and then I did a create sequence broker_id;
> 
> Are you implying that I can set the field to automatically create a nextval?



В списке pgsql-sql по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: PL/PGSQL Function problem.
Следующее
От: Qiron Adhikary
Дата:
Сообщение: Re: Copwatch database