Re: automatic insert of next sequence value?
| От | |
|---|---|
| Тема | Re: automatic insert of next sequence value? |
| Дата | |
| Msg-id | Pine.LNX.4.10.10010121322520.15718-100000@chapelperilous.net обсуждение исходный текст |
| Ответ на | automatic insert of next sequence value? (J B Bell <jbbell@intergate.ca>) |
| Список | pgsql-general |
On Thu, 12 Oct 2000, J B Bell wrote:
> I've recently started with pgsql after having used mysql. Oddly, a problem
> the latter seems to have followed me.
>
> When I set up a field with a default value to use a sequence (with "nextval"),
> It doesn't work automatically. Both using DBI and the pgsql cli, if I do
>
> INSERT INTO foo VALUES (NULL);
>
> or
>
> INSERT INTO foo VALUES ('');
>
> I get an error or null is inserted in the first case, if the field is set
> non-null, or a 0 in the second case.
It should auto-increment if you don't specify the field at all:
create sequence myseq;
create table mytable (
id int4 PRIMARY KEY default nextval('myseq'),
descr text
);
insert into mytable(descr) values ('some text');
Brett W. McCoy
http://www.chapelperilous.net
---------------------------------------------------------------------------
Is a tattoo real, like a curb or a battleship? Or are we suffering in Safeway?
В списке pgsql-general по дате отправления: